I am getting the following warning in Netbeans:
incompatible types
found : carPackage.port.search
required : carPackage.SearchResponse
In my JSP page, I have the following code:
CarService service = new CarService();
CarPort port = service.getCarPort();
SearchResponse searchResult = port.search("Toyota");
The error obviously occurs on this line:
SearchResponse searchResult = port.search("Toyota");
What datatype should I put in instead of SearchResponse?
Thanks,
Lucas
You're missing ; from the end. If CarPort.search returns SearchResponse, then your datatypes are correct.
Related
I'm trying to get a value from an XML response using REST Assured, but I'm only getting empty values.
XML example:
<?xml version="1.0" ?>
<ncresponse
orderID="50143601"
STATUS="5"
SCORING="1"
SCO_CATEGORY="G">
</ncresponse>
My code:
RestAssured.useRelaxedHTTPSValidation();
Map<String, String> body = new HashMap<>();
body.put("ORDERID", orderId);
body.put("USERID", QUERY.getUser());
body.put("PSW", QUERY.getPass());
Response validation = given().proxy(host("myproxy.com").withPort(8080)
).params(body).when().get(QUERY.getUrl());
return from(validation.asString()).get("ncresponse.STATUS");
In this case, I'm trying to get the STATUS value ("5"), but all I'm getting is "" for any attribute.
Any help would be very appreciated.
You need to first convert the response to xml type and then get the value from that response.
First you need to import the following in your code:
import io.restassured.path.xml.XmlPath;
And then your code should be:
String stringResponse = validation.asString();
XmlPath xmlPath = new XmlPath(stringResponse);
String status = xmlPath.get("ncresponse.STATUS");
Now the String status contains the value which you want.
Well, i realized that I was making a mistake here. I was trying to get an attribute from the node "ncresponse", so using "#" symbol before the attribute is neccesary:
from(validation.asString()).get("ncresponse.#STATUS");
Im closing this, thanks for all!
{"error":"OK","langId":1,
"langName":"C++",
"langVersion":"5.1.1",
"time":0,
"date":"2017-04-03 15:38:19",
"status":0,
"result":11,
"memory":0,
"signal":0,"public":false,
"source":"","output_encoded":"",
"output_type":"text","output":"",
"stderr":"",
"cmpinfo":"\/usr\/lib\/gcc\/x86_64-linux-gnu\/6\/..\/..\/..\/x86_64-linux-gnu\/Scrt1.o: In function `_start':\n(.text+0x20): undefined reference to `main'\ncollect2: error: ld returned 1 exit status\n"
}
I am getting an error, I am unable to figure out where I am going wrong?
API Call :
public interface SubmitCodeService {
#Headers("Content-Type: application/json")
#POST("/api/v3/submissions")
Call<IdResponse> postCode(#Body JSONObject code, #Query("access_token") String accessToken );
#GET("/api/v3/submissions/{id}")
Call<CodeOutputResponse> getOutput(
#Path("id") Integer submissionId,
#Query("access_token") String accessToken,
#Query("withOutput") boolean withOutput,
#Query("withSource") boolean withSource,
#Query("withStderr") boolean withStderr,
#Query("withCmpinfo") boolean withCmpinfo);
}
I am submitting a simple HelloWorld program, I am getting an id back in response, however when I try to get the output, it throws this error.
Thanks in advance for your help.
Update : I am able to get it up and running by modifying the code to this :
Call<IdResponse> postCode(#Body HashMap<String,String> code, #Query("access_token") String accessToken );
"source":""
It seems that your postCode function is not correctly sending the source code. This means no main function is defined which causes the error mentioned in your post.
You need to review how you construct the value passed to code in postCode to see if it matches what the API expects.
I would like to test Telerivet API and have the following code:
TelerivetAPI tr = new TelerivetAPI(YOUR_API_KEY);
Project project = tr.initProjectById(project_id);
Message sent_msg = project.sendMessage(Util.options(
"content", "hello world",
"to_number", "+16505550123"
));
The error I am getting is on .options(..), it says The type of options(Object...) is erroneous. How to solve that? thanks.
I have the following servlet code:
SearchResult[] basicResults = AuctionSearchClient.basicSearch(search, numToSkip, numToReturn);
request.setAttribute("search_result", basicResults);
request.getRequestDispatcher("/search.jsp").forward(request, response);
Then in my search.jsp file I have the following code:
SearchResult[] searchResult = (SearchResult[])request.getAttribute("search_result");
However I am getting an error saying:
SearchResult cannot be resolved to a type
request is an object of type HttpServletRequest.
Why am I getting this casting error?
I am facing below issue
com.mongodb.CommandFailureException: { "serverUsed" : "127.0.0.1:15847" , "errmsg" : "exception: aggregation result exceeds maximum document size (16MB)" , "code" : 16389 , "ok" : 0.0}
After googling I found some work around like using below code
{"$out":"temp_colls");
useCursor=True
1st one is working for me but its taking too much time around 3-4 minutes.
So looking for second option I have tried with below
Original code is
dbObjArray = new BasicDBObject[2]
dbObjArray[0]= cruxLevel
dbObjArray[1] = project
List<DBObject> pipeline = Arrays.asList(dbObjArray)
if (!datasetObject?.isFlat && jsonFor != 'collection-grid') {
output= dataSetCollection.aggregate(pipeline)
}else{
output= dataSetCollection.aggregate(project)
}
output.results().eachWithIndex{list,index->
dataList.add(output.results()[index])
I have tried below to get result in cursor.
1.
// Assuming MongoCollection
dataSetCollection.aggregate(pipeline).useCursor(true)
You might also need to tell it to use disk space on the server rather than doing it all in memory:
2.
// Assuming MongoCollection
dataSetCollection.aggregate(pipeline).useCursor(true).allowDiskUse(true)
If you're using an older driver (or the old API in the new driver) those two options would look like this:
3.
// Assuming DBCollection
dataSetCollection.aggregate(pipeline, AggregationOptions.builder().allowDiskUse(true)
.useCursor(true)
.build())
.useCursor(true)
And
output= dataSetCollection.aggregate(project).newAggregationOptions().outputMode(AggregationOptions.OutputMode.CURSOR).build()
Giving error for example
For "output= dataSetCollection.aggregate(project).useCursor(true)"
groovy.lang.MissingMethodException: No signature of method: com.mongodb.AggregationOutput.useCursor() is applicable for argument types: (java.lang.Boolean) values: [true]
For "output= dataSetCollection.aggregate(project).useCursor(true).allowDiskUse(true)"
groovy.lang.MissingMethodException: No signature of method: com.mongodb.AggregationOutput.useCursor() is applicable for argument types: (java.lang.Boolean) values: [true]
For "output= dataSetCollection.aggregate(project,AggregationOptions.builder()
.allowDiskUse(true)
.useCursor(true)
.build())
.useCursor(true)"
groovy.lang.MissingPropertyException: No such property: AggregationOptions for class: com.acumetric.hrat.aggregator.DataImportService
And for last one respectively.
groovy.lang.MissingMethodException: No signature of method: com.mongodb.AggregationOutput.newAggregationOptions() is applicable for argument types: () values: []
Nothing is working. Where I am going wrong please help!
Thank you.
In else block put below code
def dbObjArray = new BasicDBObject[1]
dbObjArray[0]= project
List<DBObject> flatPipeline = Arrays.asList(dbObjArray)
AggregationOptions aggregationOptions = AggregationOptions.builder()
.batchSize(100)
.outputMode(AggregationOptions.OutputMode.CURSOR)
.allowDiskUse(true)
.build();
def cursor = dataSetCollection.aggregate(flatPipeline,aggregationOptions)