I am trying to import test case results in TestLink. To do that, I have to use the method : api.getTestCaseIDByName(testCaseName, testSuiteName, projectName, testCasePathName) from the TestLinkAPI library.
The problem is I can't find out what "testCasePathName" corresponds to ...
Do you have any idea ?
It would be very helpful ! Thank you
Finally managed to find out what was the testCasePathName.
It is a String with this format : "[projectName]::[testSuiteName]::[testCaseName]" where :
- projectName is the name of your project in TestLink,
- testSuiteName is the name of your TestSuite int TestLink
- testCaseName is the name of your testCase in TestLink
Hope it will help someone someday ! :)
Presuming that the library you're speaking about is this one...
public Integer getTestCaseIDByName(String testCaseName, String testSuiteName, String testProjectName,
String testCasePathName) throws TestLinkAPIException {
return this.testCaseService.getTestCaseIDByName(testCaseName, testSuiteName, testProjectName, testCasePathName);
}
The program is going to expect a pile of Strings as the types for your parameters. You'll have to provide the names of the elements which are named. You may also want to look at the method which is referenced in the return statement to get a better understanding of how the matching system works in this library.
Related
In the context of using the OWLAPI 4.0 API, this following line of code:
ontologyIRI = IRI.create(o.getOntologyID().getOntologyIRI().toString());
returns the following string :
"Optional.of(http://www.indytion.com/music/composition)".
What I need is the sole string "http://www.indytion.com/music/composition".
I tried to declare ontologyIRI as Optional and use .get() method, .orElse(), etc. to no avail. I still have the returned string that includes the 'optional.of()' part.
My question is : How could I get the internal string?
Thank you very much for your help.
Edit : The full code the method
private void LoadOntology(String ontologyPath)
{
OWLOntologyManager man = OWLManager.createOWLOntologyManager();
OWLOntology o;
File ontologyFile = new File(ontologyPath);
Optional<IRI> ontologyIRI;
try {
o = man.loadOntologyFromOntologyDocument(ontologyFile);
ontologyIRI = Optional.of(IRI.create(String.valueOf(o.getOntologyID().getOntologyIRI()).toString()));
System.out.println("Ontology IRI is: " + ontologyIRI.get());
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
}
}
The System.out.println() returns exactly this string:
"Ontology IRI = Optional.of(http://www.indytion.com/music/composition)"
Use .get() instead of toString()
//Returns 'Optional[example]'
Optional.of("example").toString();
//Returns 'example'
Optional.of("example").get();
Short answer: Replace
Optional.of(IRI.create(String.valueOf(o.getOntologyID().getOntologyIRI()).toString()));
with
o.getOntologyID().getOntologyIRI().get();
Longer answer: you're doing an awful lot of back-and forth that's pointless at best and actively harmful in some cases:
In no particular order:
others have already commented that IRI instances are immutable, so creating a new one from an existing one is kind of pointless (if harmless).
calling Optional.of() if you don't intend to actually return an Optional is almost always a bad idea.
String.valueOf() is used to get a string-representation of some value and is usually most useful for debugging, but should not be relied on to fully round-trip everything about an object (the same applies to toString().
So basically what you're left with is this:
o.getOntologyID().getOntologyIRI() gives you an Optional<IRI>
you want an IRI.
Optional::get returns the value contained in the optional, if one exists, so you simply need to call get()
If, however the Optional is empty (i.e. there is no underlying value) then get() will throw a NoSuchElementException. This might or might not be what you want. To work around this either call isPresent() before calling get() to check if a value exists or use any of the multitude of other accessor methods, some of which have "built-in checks" in a way.
Finally, it seems that the problem was not the code itself. This is how the problem has been solved. But I don't understand why it has been solved :
I copy/paste (in the same file) the "shouldAddObjectPropertyAssertions()" example from OWLAPI4 examples -> This example code runs OK (but does not use the getOntologyID() method as I do).
Change SDKs to another minor version '1.8.0_61'
Change again with initial and desired SDK '1.8.0_131'
Invalidate caches and restart the IDE
Problem solved. The exactly same code :
ontologyIRI = o.getOntologyID().getOntologyIRI().get();
System.out.println("Ontology IRI is: " + ontologyIRI);
Now returns the expected string value : "http://www.indytion.com/music/composition" and not "Optional.of(http://www.indytion.com/music/composition)" anymore.
If someone can explain why it has been fixed, I would be very glad.
Thank you again for your help.
I am using response retrieved from one endpoint as path param in another endpoint.
However, when used in URI, it throws java.net.URISyntaxException: Illegal character in path.
//Post the endpoint
Response resp2 = RestAssured.given().
pathParam("id", build).
log().all().
when().urlEncodingEnabled(false).post("https://abc/{id}");
This is because the value of id used in uri is with double quotes like :-
https://abc/"id".
How can I get rid of these double quotes so as to use the value of id in uri , please advise.
First talk to the developer about this, because the nature of path param (/{id}) is to be replaced by a legitimate value (not enclosed in quotes); something like https://abc/23 or https://abc/param
I would not suggest any work-around for this as this is implemented in a wrong way from REST end point definition. You might go ahead and raise a defect against this.
Taking a shot in the dark here because I feel like the issue could possibly be coming from how you're getting the string from that response. If you're pulling it from a JSON using GSON or similar:
String name = myResponseJsonObject.get("member_name")
System.out.Println(name);
will print
"John"
whereas
String name = myResponseJsonObject.get("member_name").getAsString()
System.out.Println(name);
will give you
John
A small detail but this has tripped me up when using GSON and others when working with JSONs in java.
Thank you John and Mohan for your time , I really appreciate it.
I resolved this issue yesterday evening using Stringof function which removed the double quotes and provided me the String like value.
Does IntelliJ IDEA (2018.2+) offer the formatting option for comma-first style in Java?
public void example(
String one
, String two
, String three) { ... }
I've read about it somewhere but I can't find it anymore.
There is no such option at the moment. Please vote for the related request on YouTrack: https://youtrack.jetbrains.com/issue/IDEABKL-6965
I am trying to code a simple bit of java but i cannot get it to compile
I have defined the objects within my class as so
public class teams
{
public char sponsor;
public char tires;
I am trying to set the default value of class sponsor to N/A
public teams()
{
this.sponsor = "N/A";
}
Can anyone figure out why it wont work? Im fairly new to java and i know this is probably extremely simple, any help would be appreciated!
EDIT
So thanks to Kevin Esche, I managed to get it to compile by using,
this.sponsor = 'N';
How would I get the term N/A instead of just N? Would I use unicode?, and if yes how do you format it?
Either you make your sponsor a String
public String sponsor;
Or you store only one character in it:
sponsor = 'X';
Good Luck.
i have thrift service with a function returning list of Object ABC:
struct ABC
{
1: string user_id;
2: string foo;
3: optional list<string> data;
}
list<ABC> getABCByUser(1:required string user_id, 2:i32 limit,3:i32 pageId, 4:string lastDocID)
throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te)
server side written by c++
I print out result returned by server side, data in ABC instance is NOT null in the response of getABCByUser.
How ever on client side which is written by java:
I set break point in the code generated by thrift on java side, data in ABC instance is null, other fields are not null.
it looks like a issue on the client side. Any idea how to fix this issue?
thanks in advance!
I encounter the same problem with you. I found that if delete the "optional" modifier before list, the return value will be right. But I don't know why we can't use "optional" before list.
If you think you may have found a bug, please open a JIRA ticket and add your reproducible test case. This makes it easier for others to have a look at it. Thank you!