@Test(expectedExceptions = NullPointerException.class) public void testGetSlotStatusNull() { resource.getSlotStatus(null, MockUriInfo.from(URI.create("http://localhost/v1/agent/slot/null"))); }
public static UriInfo from(URI requestUri) { return new MockUriInfo(requestUri); }
public MultivaluedMap<String, String> getQueryParameters(boolean decode) { return decodeQuery(getRequestUri().getRawQuery(), decode); }
public String getPath(boolean decode) { // todo decode is ignored return getRequestUri().getRawPath().substring(getBaseUri().getRawPath().length()); }
public String getPath() { return getPath(true); }
public MultivaluedMap<String, String> getQueryParameters() { return getQueryParameters(true); }
public List<PathSegment> getPathSegments() { return getPathSegments(true); }
public MultivaluedMap<String, String> getPathParameters() { return getPathParameters(true); }
public List<String> getMatchedURIs() { return getMatchedURIs(true); }
public UriBuilder getBaseUriBuilder() { return UriBuilder.fromUri(getBaseUri()); }
public UriBuilder getAbsolutePathBuilder() { return UriBuilder.fromUri(getAbsolutePath()); }
public List<PathSegment> getPathSegments(boolean decode) { Builder<PathSegment> builder = ImmutableList.builder(); for (String path : PATH_SPLITTER.split(getPath(decode))) { builder.add(new ImmutablePathSegment(path)); } return builder.build(); }
@Test public void testAll() { assertTrue(SlotFilterBuilder.build(MockUriInfo.from("fake://localhost?all&state=unknown"), true, ImmutableList.<UUID>of()).apply(status)); assertTrue(SlotFilterBuilder.build(MockUriInfo.from("fake://localhost?all&state=running"), true, ImmutableList.<UUID>of()).apply(status)); assertTrue(SlotFilterBuilder.build(MockUriInfo.from("fake://localhost?all&host=host"), true, ImmutableList.<UUID>of()).apply(status)); }
public static UriInfo from(String requestUri) { return new MockUriInfo(URI.create(requestUri)); }
@Test public void testGetSlotStatusUnknown() { Response response = resource.getSlotStatus(UUID.randomUUID(), MockUriInfo.from("http://localhost/v1/agent/slot/unknown")); assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); }
@Test(expectedExceptions = InvalidSlotFilterException.class) public void testSetStateNoFilter() { resource.setState("running", MockUriInfo.from("http://localhost/v1/slot/lifecycle"), null); }
@Test(expectedExceptions = InvalidSlotFilterException.class) public void testEmptyFilter() { SlotFilterBuilder.build(MockUriInfo.from("fake://localhost"), true, ImmutableList.<UUID>of()).apply(status); }
@Test public void testAll() { assertTrue(AgentFilterBuilder.build(MockUriInfo.from("fake://localhost?all&state=online"), ImmutableList.<String>of(), ImmutableList.<UUID>of()).apply(status)); assertTrue(AgentFilterBuilder.build(MockUriInfo.from("fake://localhost?all&state=offline"), ImmutableList.<String>of(), ImmutableList.<UUID>of()).apply(status)); assertTrue(AgentFilterBuilder.build(MockUriInfo.from("fake://localhost?all&host=host"), ImmutableList.<String>of(), ImmutableList.<UUID>of()).apply(status)); }
@Test public void testGetSlotStatusUnknown() { Response response = resource.getSlotStatus(UUID.randomUUID(), MockUriInfo.from("http://localhost/v1/agent/slot/unknown")); assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); }
@Test public void testAll() { assertTrue(AgentFilterBuilder.build(MockUriInfo.from("fake://localhost?all&state=online"), ImmutableList.<String>of(), ImmutableList.<UUID>of()).apply(status)); assertTrue(AgentFilterBuilder.build(MockUriInfo.from("fake://localhost?all&state=offline"), ImmutableList.<String>of(), ImmutableList.<UUID>of()).apply(status)); assertTrue(AgentFilterBuilder.build(MockUriInfo.from("fake://localhost?all&host=host"), ImmutableList.<String>of(), ImmutableList.<UUID>of()).apply(status)); }