use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getParamsFromBuilderTest.
/*
* @testName: getParamsFromBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:792;
*
* @test_Strategy: Returns an immutable map that includes all the link
* parameters defined on this link. If defined, this map will include entries
* for "rel", "title" and "type".
*/
@Test
public void getParamsFromBuilderTest() throws Fault {
Builder builder = Link.fromUri(uri("get"));
builder.rel("RELREL").title("TITLETITLE").type("TYPETYPE").param("NEWPARAM", "NEWPARAMVALUE");
Link link = builder.build();
String value;
Map<String, String> params = link.getParams();
value = params.get("title");
assertContains(value, "titletitle");
value = params.get("rel");
assertContains(value, "RELREL");
value = params.get("type");
assertContains(value, "typetype");
value = params.get("NEWPARAM");
assertContains(value, "newparamvalue");
logMsg(params, "found as expected");
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromPathWithUriTemplateParamsTest.
/*
* @testName: fromPathWithUriTemplateParamsTest
*
* @assertion_ids: JAXRS:JAVADOC:1038;
*
* @test_Strategy: Convenience method to build a link from a path. Equivalent to
* fromUriBuilder(UriBuilder.fromPath(path)).
*/
@Test
public void fromPathWithUriTemplateParamsTest() throws Fault {
String path = "somewhere/somehow/{p1}/{p2}";
String param1 = "param1", param2 = "param2";
UriBuilder builder = UriBuilder.fromPath(path);
Link.Builder linkBuilder = Link.fromUriBuilder(builder);
Link.Builder fromPathBuilder = Link.fromPath(path);
String fromUriBuilderString = linkBuilder.build(param1, param2).toString();
String fromPathString = fromPathBuilder.build(param1, param2).toString();
assertEquals(fromUriBuilderString, fromPathString, "fromUriBuilder(UriBuilder.fromPath(,", path, "))=", fromUriBuilderString, "differs from Link.fromPath(", path, ")", fromPathString);
logMsg("fromUriBuilder(UriBuilder.fromPath(", path, ")) is equivalent to fromPath(", path, ")", "The link is", fromPathString);
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getRelsIsEmptyTest.
/*
* @testName: getRelsIsEmptyTest
*
* @assertion_ids: JAXRS:JAVADOC:956;
*
* @test_Strategy: Returns the value associated with the link "rel" param as a
* list of strings or the empty list if "rel" is not defined.
*/
@Test
public void getRelsIsEmptyTest() throws Fault {
Builder builder = Link.fromUri(uri("get"));
Link link = builder.build();
assertNotNull(link.getRels(), "#getRels is null");
assertEqualsInt(link.getRels().size(), 0, "Unexpected #getRels size", link.getRels().size(), "Should be 0");
logMsg("#getRel() return empty list as expected");
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromUriBuilderTest.
/*
* @testName: fromUriBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:1005;
*
* @test_Strategy: Create a new builder instance initialized from a URI builder.
*/
@Test
public void fromUriBuilderTest() throws Fault {
String segment = "goto/label/ten/";
Link link = Link.fromUri(uri(segment)).build();
UriBuilder builder = link.getUriBuilder();
Builder fromBuilder = Link.fromUriBuilder(builder);
String sBuilder = builder.build().toASCIIString();
String sFromBuilder = fromBuilder.build().getUri().toASCIIString();
assertContains(sFromBuilder, sBuilder, "Original builder", sBuilder, "not found in #fromUriBuilder", sFromBuilder);
logMsg("#fromUriBuilder", sFromBuilder, "contains the original", sBuilder);
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getTitleTest.
/*
* @testName: getTitleTest
*
* @assertion_ids: JAXRS:JAVADOC:794;
*
* @test_Strategy: Returns the value associated with the link "title" param, or
* null if this param is not specified.
*/
@Test
public void getTitleTest() throws Fault {
Builder builder = Link.fromUri(uri("get"));
builder.rel("RELREL").title("TITLETITLE").type("TYPETYPE");
Link link = builder.build();
String title = link.getTitle();
assertTrue(title != null, "#getTitle did NOT return expected title");
assertContains(title, "TITLETITLE");
}
Aggregations