Error error while modifying scala file Gatling - web-services

i have a error when i try modifyng scala file.
When i want to insert a new scripts, the original script.It does not appear to me to execute in Gatling.bat or only it executes the previous requests to which I am modifying
Example i need to insert new code in Request12,but when i try it happens what i mentioned above, only the requests from 0 to 11 are executed or simply my scala file is not displayed to run in Gatling.bat
Has anyone else had this error?
EDIT:
My code: In this file i want to add request 12
package blablabla
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class SearchCustomerClientNumber2 extends Simulation {
val httpProtocol = http
.baseURL("http://URL")
.inferHtmlResources()
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("es-CL,es;q=0.8,en-US;q=0.5,en;q=0.3")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0")
Variables to read CSV FILE
val csvFeeder = csv("Users.csv").circular // use a comma separator
val ic= feed(csvFeeder)
//When i put this variables above the request(request 12) only executes the first 11 request and when I put them here it does not read the csv file
Help me!! :c
val headers_0 = Map("Upgrade-Insecure-Requests" -> "1")
val headers_1 = Map("Accept" -> "*/*")
val headers_12 = Map(
"Content-length" -> "1135",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_13 = Map(
"Content-length" -> "388",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_17 = Map(
"Content-length" -> "306",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_19 = Map(
"Content-length" -> "390",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_21 = Map(
"Content-length" -> "400",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_23 = Map(
"Content-length" -> "396",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_29 = Map(
"Content-length" -> "409",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_30 = Map(
"Content-length" -> "435",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_32 = Map(
"Content-length" -> "449",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_34 = Map(
"Content-length" -> "533",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_35 = Map(
"Content-length" -> "534",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_42 = Map(
"Content-length" -> "453",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_44 = Map(
"Content-length" -> "459",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_45 = Map(
"Content-length" -> "813",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_46 = Map(
"Content-length" -> "940",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val headers_54 = Map(
"Content-length" -> "376",
"Content-type" -> "text/xml; charset=utf-8",
"SOAPAction" -> """""""")
val uri1 = "URL/b0001b/"
val scn = scenario("SearchCustomerClientNumber2")
.exec(http("request_0")
.get("/bei010Web/")
.headers(headers_0)
.resources(http("request_1")
.get("/bei010Web/images/logo.jpg")
.headers(headers_1),
http("request_2")
.get("/bei010Web/images/***.jpg")
.headers(headers_1),
http("request_3")
.get("/bei010Web/images/flagES.png")
.headers(headers_1),
http("request_4")
.get("/bei010Web/images/****.jpg")
.headers(headers_1),
http("request_5")
.get("/bei010Web/images/****.jpg")
.headers(headers_1),
http("request_6")
.get("/bei010Web/images/flagUSA.png")
.headers(headers_1),
http("request_7")
.get("/bei010Web/images/*****.jpg")
.headers(headers_1),
http("request_8")
.get("/bei010Web/images/***.jpg")
.headers(headers_1)))
.pause(1)
.exec(http("request_9")
.get("/bei010Web/bei010/sp_MX/bei10.jsp")
.headers(headers_0))
.pause(1)
.exec(http("request_10")
.get("/bei010Web/WEBSERVICE?WSDL")
.resources(http("request_11")
.get("/bei010Web/WEBSERVICE?WSDL")))
.pause(4)
//before:
.exec(http("request_12")
.post("/bei010Web/webservicesecurity")
.headers(headers_12)
.body(RawFileBody("SearchAccountNumberxxx_0012_request.txt"))
//This code i want to add:
// I want:
.exec(http("request_12")
.post("/bei010Web/WEBSERVICESECURITY")
.headers(headers_12)
.body(StringBody("""<SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<tns:authenticateUserxmlns:tns="http://******.com/">
<login>${Username}</login>
<password>${pass}</password>
<program>1</program>
</tns:authenticateUser>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>"""))
.resources(http("request_13")
.post("/bei010Web/WEBSERVICE")
.headers(headers_13)
.body(RawFileBody("SearchCustomerClientNumber2_0013_request.txt")),
http("request_14")
.get("/bei010Web/WEBSERVICE?WSDL"),
http("request_15")
.get("/bei010Web/WEBSERVICE?WSDL"),
http("request_16")
.get("/bei010Web/DWEBSERVICE?WSDL"),
http("request_17")
.post("/bei010Web/WEBSERVICE")
.headers(headers_17)
.body(RawFileBody("SearchCustomerClientNumber2_0017_request.txt")),
http("request_18")
.get("/bei010Web/WEBSERVICE?WSDL"),
http("request_19")
.post("/bei010Web/DelinquentServiceService")
.headers(headers_19)
.body(RawFileBody("SearchCustomerClientNumber2_0019_request.txt")),
http("request_20")
.get("/bei010Web/WEBSERVICE?WSDL"),
http("request_21")
.post("/bei010Web/WEBSERVICE")
.headers(headers_21)
.body(RawFileBody("SearchCustomerClientNumber2_0021_request.txt")),
http("request_22")
.post("/bei010Web/WEBSERVICE")
.headers(headers_13)
.body(RawFileBody("SearchCustomerClientNumber2_0022_request.txt")),
http("request_23")
.post("/bei010Web/WEBSERVICE")
.headers(headers_23)
.body(RawFileBody("SearchCustomerClientNumber2_0023_request.txt"))))
This code is in another file:
.exec(http("request_12")
.post("/bei010Web/WEBSERVICESECURITY")
.headers(headers_12)
.body(StringBody("""<SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<tns:authenticateUserxmlns:tns="http://******.com/">
<login>${Username}</login>
<password>${pass}</password>
<program>1</program>
</tns:authenticateUser>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>"""))
**I changed some names, but are working,except for what i want to add
Help me please.
Regards

Related

Scala -Create Map from Spark DataFrame

I have a Spark DataFrame and I want to create Map and store values as Map[String, Map[String, String]].
I am not getting idea to do it, any help would be appreciated.
Below is Input and Output Format :
Input :
+-----------------+------------+---+--------------------------------+
|relation |obj_instance|obj|map_value |
+-----------------+------------+---+--------------------------------+
|Start~>HInfo~>Mnt|Mnt |Mnt|[Model -> 2000, Version -> 1.0] |
|Start~>HInfo~>Cbl|Cbl-3 |Cbl|[VSData -> XYZVN, Name -> Smart]|
+-----------------+------------+---+--------------------------------+
Output :
Map(relation -> Start~>HInfo~>Mnt, obj_instance -> Mnt, obj -> Mnt, Mnt -> Map(Model -> 2000, Version -> 1.0))
Map(relation -> Start~>HInfo~>Cbl, obj_instance -> Cbl-3, obj -> Cbl, Cbl -> Map(VSData -> XYZVN, Name -> Smart))
Code, I'm trying but not success :
var resultMap: Map[Any, Any] = Map()
groupedDataSet.foreach( r => {
val key1 = "relation".toString
val value1 = r(0).toString
val key2 = "obj_instance".toString
val value2 = r(1).toString
val key3 = "obj".toString
val value3 = r(2).toString
val key4 = r(2).toString
val value4 = r(3)
resultMap += (key1 -> value1, key2 -> value2, key3 -> value3, key4 -> value4)
})
resultMap.foreach(println)
Please help.
Below is the Code to create Test DataFrame and Map Column
import org.apache.spark.SparkConf
import org.apache.spark.sql.{Column, SparkSession}
import org.apache.spark.sql.functions._
object DFToMap extends App {
//Creating SparkSession
lazy val conf = new SparkConf().setAppName("df-to-map").set("spark.default.parallelism", "2")
.setIfMissing("spark.master", "local[*]")
lazy val sparkSession = SparkSession.builder().config(conf).getOrCreate()
import sparkSession.implicits._
// Creating raw DataFrame
val rawTestDF = Seq(("Start~>HInfo~>Cbl", "Cbl-3", "Cbl", "VSData", "XYZVN"), ("Start~>HInfo~>Cbl", "Cbl-3", "Cbl", "Name", "Smart"),
("Start~>HInfo~>Mnt", "Mnt", "Mnt", "Model", "2000"), ("Start~>HInfo~>Mnt", "Mnt", "Mnt", "Version", "1.0"))
.toDF("relation", "obj_instance", "obj", "key", "value")
rawTestDF.show(false)
val joinTheMap = udf { json_value: Seq[Map[String, String]] => json_value.flatten.toMap }
val groupedDataSet = rawTestDF.groupBy("relation", "obj_instance", "obj").agg(collect_list(map(col("key"), col("value"))) as "map_value_temp").withColumn("map_value", joinTheMap(col("map_value_temp")))
.drop("map_value_temp")
groupedDataSet.show(false) //This is the Input DataFrame.
}
Final Output Json from Map :
[{"relation":"Start~>HInfo~>Mnt","obj_instance":"Mnt","obj":"Mnt","Mnt":{"Model":"2000","Version":"1.0"}}
{"relation":"Start~>HInfo~>Cbl","obj_instance":"Cbl-3","obj:"Cbl","Cbl":{"VSData":"XYZVN","Name":"Smart"}}]
Note : I don't want to use any Spark groupBy, pivot, agg as Spark streaming doesn't support multi aggregation. Hence I want to get it with pure Scala code. Kindly help.
Created custom UDF to parse & generate data in JSON format.
import org.json4s.native.JsonMethods._
import org.json4s._
import org.json4s.JsonDSL._
def toJson(relation:String,obj_instance: String,obj: String,map_value: Map[String,String]) = {
compact(render(
JObject("relation" -> JString(relation),
"obj_instance" -> JString(obj_instance),
"obj" -> JString(obj),
obj -> map_value)))
}
import org.apache.spark.sql.functions._
val createJson = udf(toJson _)
val df = Seq(("Start~>HInfo~>Mnt","Mnt","Mnt",Map("Model" -> "2000", "Version" -> "1.0")),("Start~>HInfo~>Cbl","Cbl-3","Cbl",Map("VSData" -> "XYZVN", "Name" -> "Smart"))).toDF("relation","obj_instance","obj","map_value")
df.select(createJson($"relation",$"obj_instance",$"obj",$"map_value").as("json_map")).show(false)
+-----------------------------------------------------------------------------------------------------------+
|json_map |
+-----------------------------------------------------------------------------------------------------------+
|{"relation":"Start~>HInfo~>Mnt","obj_instance":"Mnt","obj":"Mnt","Mnt":{"Model":"2000","Version":"1.0"}} |
|{"relation":"Start~>HInfo~>Cbl","obj_instance":"Cbl-3","obj":"Cbl","Cbl":{"VSData":"XYZVN","Name":"Smart"}}|
+-----------------------------------------------------------------------------------------------------------+

HTTP client post with optional splat argument not compiled

I would like to send HTTP post request by using
HTTP::Client#post(path, headers : HTTP::Headers | ::Nil = nil, *, form : Hash(String, String) | NamedTuple)
I try to do this
url = "https://api.authy.com/protected/json/phones/verification/start"
headers = HTTP::Headers{"X-Authy-API-Key" => api_key}
form = {
via: "sms",
country_code: country_code,
phone_number: phone_number,
code_length: 6,
locale: "ru",
}.to_h
response = HTTP::Client.post(url, headers: headers, form: form)
Unfortunately, I got compilation error
no argument named 'form'
Matches are:
- HTTP::Client#post(path, headers : HTTP::Headers | ::Nil = nil, body : BodyType = nil) (trying this one)
- HTTP::Client#post(path, headers : HTTP::Headers | ::Nil = nil, body : BodyType = nil, &block)
- HTTP::Client#post(path, headers : HTTP::Headers | ::Nil = nil, *, form : String | IO)
- HTTP::Client#post(path, headers : HTTP::Headers | ::Nil = nil, *, form : String | IO, &block)
- HTTP::Client#post(path, headers : HTTP::Headers | ::Nil = nil, *, form : Hash(String, String) | NamedTuple)
- HTTP::Client#post(path, headers : HTTP::Headers | ::Nil = nil, *, form : Hash(String, String) | NamedTuple, &block)
What is correct way to do it?
This compilation error happens because .to_h returns a Hash(Symbol, Int32 | String) on your named tuple, and that is incompatible with any of the definitions for HTTP::Client.post.
To solve this, I suggest to explicitly define form as a Hash(String, String) and replace the keys and values by their string representation:
form : Hash(String, String) = {
"via" => "sms",
"country_code" => country_code.to_s, # assuming this is not a string
"phone_number" => phone_number,
"code_length" => "6",
"locale" => "ru",
}

SharePoint Framework httpClient.post to _vti_bin/lists.asmx response

i'm trying to rewrite a javascript webpart to Sharepoint Framework.
in this webpart i need to do a soap post to /_vti_bin/Lists.asmx in order to get all the events from a calendar list expanded, with the recurring events in it.
The javascript code looks like this
wsURL = webUrl + "/_vti_bin/Lists.asmx";
var xmlCall =
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body>" +
"<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
"<listName>" + calendarList + "</listName>" +
"<query>" +
"<Query>" +
"<Where>" +
"<DateRangesOverlap>" +
"<FieldRef Name=\"EventDate\" />" +
"<FieldRef Name=\"EndDate\" />" +
"<FieldRef Name=\"RecurrenceID\" />" +
"<Value Type='DateTime'><Year/></Value>" +
"</DateRangesOverlap>" +
"</Where>" +
"</Query>" +
"</query>" +
"<queryOptions>" +
"<QueryOptions>" +
"<ExpandRecurrence>TRUE</ExpandRecurrence>" +
"</QueryOptions>" +
"</queryOptions>" +
"</GetListItems>" +
"</soap:Body></soap:Envelope>";
var result = [];
$.ajax({
url: wsURL,
type: "POST",
dataType: "xml",
async: false,
data: xmlCall,
complete: function (xData, status) {
if (status === "success") {
var root = $(xData.responseText);
root.find("listitems").children().children().each(function () {
$this = $(this);
var ids = $this.attr("ows_UniqueId").split(";");
var rec = $this.attr("ows_fRecurrence");
result.push({
"StartTime": $this.attr("ows_EventDate"),
"EndTime": $this.attr("ows_EndDate"),
"Title": $this.attr("ows_Title"),
"Recurrence": (rec === "1" ? true : false),
"Description": $this.attr("ows_Description"),
"Guid": ids[1],
"Id": ids[0],
});
});
}
},
contentType: "text/xml; charset=\"utf-8\""
});
return result;
};
But now i'm trying to rewrite this code in typescript, but i cannot seem to get the responseText back?
this is my TypeScript function
private makeRequest(listName: string): Promise<HttpClientResponse> {
let wsURL = this.context.pageContext.web.absoluteUrl + "/_vti_bin/Lists.asmx";
var xmlCall =
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body>" +
"<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
"<listName>" + listName + "</listName>" +
"<query>" +
"<Query>" +
"<Where>" +
"<DateRangesOverlap>" +
"<FieldRef Name=\"EventDate\" />" +
"<FieldRef Name=\"EndDate\" />" +
"<FieldRef Name=\"RecurrenceID\" />" +
"<Value Type='DateTime'><Year/></Value>" +
"</DateRangesOverlap>" +
"</Where>" +
"</Query>" +
"</query>" +
"<queryOptions>" +
"<QueryOptions>" +
"<ExpandRecurrence>TRUE</ExpandRecurrence>" +
"</QueryOptions>" +
"</queryOptions>" +
"</GetListItems>" +
"</soap:Body></soap:Envelope>";
const requestHeaders: Headers = new Headers();
requestHeaders.append('Content-type', "text/xml; charset=\"utf-8\"");
const httpClientOptions: IHttpClientOptions = {
body: xmlCall,
headers: requestHeaders
};
console.log("About to make REST API request.");
return this.context.httpClient.post(
wsURL,
HttpClient.configurations.v1,
httpClientOptions)
.then((response: HttpClientResponse) => {
console.log("REST API response received.");
console.log(response);
console.log(response.text());
console.log(response.json());
debugger;
return response.json();
});
}
How can i do a post to a soap webservice from my Sharepoint Framework in TypeScript and get the xml response back?
Well, i got everything working.
The problem is you cannot add a debugger code in an ASYNC post call, so that will never work. Second, the response from the SOAP post to lists.asmx is not a response of type HttpClientResponse, but just a plain string with xml.
so the function looks like this now:
private makeRequest(listName: string): Promise<string> {
let wsURL = this.context.pageContext.web.absoluteUrl + "/_vti_bin/Lists.asmx";
var xmlCall = `
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>${listName}</listName>
<query>
<Query>
<Where>
<DateRangesOverlap>
<FieldRef Name="EventDate" />
<FieldRef Name="EndDate" />
<FieldRef Name="RecurrenceID" />
<Value Type="DateTime"><Year/></Value>
</DateRangesOverlap>
</Where>
</Query>
</query>
<queryOptions>
<QueryOptions>
<ExpandRecurrence>TRUE</ExpandRecurrence>
</QueryOptions>
</queryOptions>
</GetListItems>
</soap:Body>
</soap:Envelope>
`;
const requestHeaders: Headers = new Headers();
requestHeaders.append('Content-type', "text/xml; charset=\"utf-8\"");
const httpClientOptions: IHttpClientOptions = {
body: xmlCall,
headers: requestHeaders
};
console.log("About to make REST API request.");
return this.context.httpClient.post(
wsURL,
HttpClient.configurations.v1,
httpClientOptions)
.then(data => {
var result: any[];
if(data.status == 200)
{
return data.text(); //returning the XML text of the response
}
else
{
return "";
}
});
}
and the function is called like this
this.makeRequest(this.properties.listdropdown)
.then((data) => {
let vArrEvents:any[] = [];
$(data).find("listitems").children().children().each((index, element) => {
let ids = $(element).attr("ows_UniqueId").split(";");
let rec = $(element).attr("ows_fRecurrence");
let strMatch:any[] = $(element).attr("ows_EventDate").match(/^(\d+)-(\d+)-(\d+) (\d+)\:(\d+)\:(\d+)$/);
let startDate = new Date(strMatch[1], strMatch[2] - 1, strMatch[3], strMatch[4], strMatch[5], strMatch[6]);
let today = new Date();
today.setHours(0,0,0);
if(startDate >= today)
{
vArrEvents.push({
"StartTime": $(element).attr("ows_EventDate"),
"EndTime": $(element).attr("ows_EndDate"),
"Title": $(element).attr("ows_Title"),
"Recurrence": (rec === "1" ? true : false),
"Description": $(element).attr("ows_Description"),
"Guid": ids[1],
"Id": ids[0],
});
}
});
this.showEvents(vArrEvents);
this.context.statusRenderer.clearLoadingIndicator(this.domElement);
});

Scala Convert a Map[String, List[String]] to a Map[String, String]

Would someone be able to help me convert Map[String, List[String]] to a Map[String, String] in scala?
Here is the Map[String, List[String]] as follows:
val pets: Map[String, List[String]] = Map(
"home" -> List("cat", "dog", "fish"),
"farm" -> List("cow", "horse"),
"wild" -> List("tiger", "elephant")
)
That needs to be converted to Map[String, String] as follows:
val pets2: Map[String, String] = Map(
"home" -> "cat",
"home" -> "dog",
"home" -> "fish",
"farm" -> "cow",
"farm" -> "horse",
"wild" -> "tiger",
"wild" -> "elephant"
)
As mentioned before each key in a Map is unique.
That said, what you can do is convert the map to a sequence of tuples:
pets.toSeq.flatMap { case (key, list) => list.map(key -> _) }
will give you:
ArrayBuffer(
(home,cat),
(home,dog),
(home,fish),
(farm,cow),
(farm,horse),
(wild,tiger),
(wild,elephant)
)
Maps cannot have repeated keys.

Scala: split Map size n to List(Maps max size 3)

In:
Map("k1" -> "v1", "k2" -> "v2", "k3" -> "v3", "k4" -> "v4", "k5" -> "v5", "k6" -> "v6", "k7" -> "v7", "k8" -> "v8", "k9" -> "v9", "k0" -> "v0")
Out:
List(Map("k1" -> "v1", "k2" -> "v2", "k3" -> "v3), Map("k4" -> "v4", "k5" -> "v5", "k6" -> "v6), Map("k7" -> "v7", "k8" -> "v8", "k9" -> "v9), Map("k0" -> "v0"))
val a = Map("k1" -> "v1", "k2" -> "v2", "k3" -> "v3", "k4" -> "v4", "k5" -> "v5", "k6" -> "v6", "k7" -> "v7", "k8" -> "v8", "k9" -> "v9", "k0" -> "v0")
a.grouped(3).toList
This gives you:
res2: List[scala.collection.immutable.Map[String,String]] = List(Map(k2 -> v2, k0 -> v0, k5 -> v5), Map(k9 -> v9, k6 -> v6, k7 -> v7), Map(k1 -> v1, k4 -> v4, k3 -> v3), Map(k8 -> v8))
The only thing it's not ordered
To keep the order you can do something like this:
a.toList.sortBy(_._1).grouped(3).toList.map(_.toMap)
Which gives you:
res6: List[scala.collection.immutable.Map[String,String]] = List(Map(k0 -> v0, k1 -> v1, k2 -> v2), Map(k3 -> v3, k4 -> v4, k5 -> v5), Map(k6 -> v6, k7 -> v7, k8 -> v8), Map(k9 -> v9))
Note that your initial Map is not sorted properly (the last element is "k0", but it should be the first one). But if you want to keep the insertion order and have the list of maps grouped by 3 this one should work:
val b = scala.collection.mutable.LinkedHashMap("k1" -> "v1", "k2" -> "v2", "k3" -> "v3", "k4" -> "v4", "k5" -> "v5", "k6" -> "v6", "k7" -> "v7", "k8" -> "v8", "k9" -> "v9", "k0" -> "v0")
b.toList.grouped(3).toList.map(_.toMap)
This results to:
res8: List[scala.collection.immutable.Map[String,String]] = List(Map(k1 -> v1, k2 -> v2, k3 -> v3), Map(k4 -> v4, k5 -> v5, k6 -> v6), Map(k7 -> v7, k8 -> v8, k9 -> v9), Map(k0 -> v0))