use of jakarta.ws.rs.core.Link 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 in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromResourceThrowsIAEWhenNullClassTest.
/*
* @testName: fromResourceThrowsIAEWhenNullClassTest
*
* @assertion_ids: JAXRS:JAVADOC:1039;
*
* @test_Strategy: IllegalArgumentException - if any argument is null or no
* method is found.
*/
@Test
public void fromResourceThrowsIAEWhenNullClassTest() throws Fault {
try {
Link link = Link.fromResource((Class<?>) null).build();
logMsg("Unexpectedly thrown no exception and created link", link);
} catch (IllegalArgumentException e) {
logMsg("IllegalArgumentException has been thrown as expected", e);
}
}
use of jakarta.ws.rs.core.Link 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 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 in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromResourceWithMediaTypeTest.
/*
* @testName: fromResourceWithMediaTypeTest
*
* @assertion_ids: JAXRS:JAVADOC:1004;
*
* @test_Strategy: Convenience method to build a link from a resource.
*/
@Test
public void fromResourceWithMediaTypeTest() throws Fault {
Link link = Link.fromResource(ResourceWithProduces.class).build();
String resource = link.toString();
assertContains(resource, "<producesresource>");
assertNotContains(resource, "type=\"" + MediaType.TEXT_HTML + "\"");
logMsg("Link", resource, "has been created");
}
Aggregations