Search in sources :

Example 31 with PathSegment

use of javax.ws.rs.core.PathSegment in project scheduling by ow2-proactive.

the class WorkflowVariablesTransformerTest method testEmptyMap.

@Test
public void testEmptyMap() {
    PathSegment pathSegment = mock(PathSegment.class);
    MultivaluedMap<String, String> multivalueMap = new MultivaluedHashMap();
    when(pathSegment.getMatrixParameters()).thenReturn(multivalueMap);
    Map<String, String> variables = workflowVariablesTransformer.getWorkflowVariablesFromPathSegment(pathSegment);
    assertThat(variables, is(nullValue()));
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) PathSegment(javax.ws.rs.core.PathSegment) Test(org.junit.Test)

Example 32 with PathSegment

use of javax.ws.rs.core.PathSegment in project scheduling by ow2-proactive.

the class WorkflowVariablesTransformerTest method testTwoVariablesNullMap.

@Test
public void testTwoVariablesNullMap() {
    Map<String, String> expectedVariables = Maps.newHashMap();
    expectedVariables.put("KEY1", "");
    expectedVariables.put("KEY2", "");
    PathSegment pathSegment = mock(PathSegment.class);
    MultivaluedMap<String, String> multivalueMap = new MultivaluedHashMap();
    multivalueMap.put("KEY1", null);
    multivalueMap.put("KEY2", null);
    when(pathSegment.getMatrixParameters()).thenReturn(multivalueMap);
    Map<String, String> variables = workflowVariablesTransformer.getWorkflowVariablesFromPathSegment(pathSegment);
    assertThat(variables, is(expectedVariables));
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) PathSegment(javax.ws.rs.core.PathSegment) Test(org.junit.Test)

Example 33 with PathSegment

use of javax.ws.rs.core.PathSegment in project Payara by payara.

the class CompositeResource method getParentUri.

private URI getParentUri(boolean isCollectionChild) throws Exception {
    List<PathSegment> pathSegments = this.uriInfo.getPathSegments();
    // go up a level to get to the parent
    int count = pathSegments.size() - 1;
    if (isCollectionChild) {
        // collection children have the url pattern .../foos/id/myfoo. need to go up another level
        count--;
    }
    // [0] = 'javaservice', which is a resource
    if (count <= 0) {
        // top level resource
        return null;
    }
    UriBuilder bldr = this.uriInfo.getBaseUriBuilder();
    for (int i = 0; i < count; i++) {
        bldr.path(pathSegments.get(i).getPath());
    }
    return bldr.build();
}
Also used : PathSegment(javax.ws.rs.core.PathSegment) UriBuilder(javax.ws.rs.core.UriBuilder)

Aggregations

PathSegment (javax.ws.rs.core.PathSegment)33 Test (org.junit.Test)13 UriInfo (javax.ws.rs.core.UriInfo)10 Map (java.util.Map)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 URI (java.net.URI)4 List (java.util.List)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)4 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)4 Response (javax.ws.rs.core.Response)4 MetadataMap (org.apache.cxf.jaxrs.impl.MetadataMap)4 Access (io.druid.server.security.Access)3 AuthorizationInfo (io.druid.server.security.AuthorizationInfo)3 Resource (io.druid.server.security.Resource)3 TreeMap (java.util.TreeMap)3 Produces (javax.ws.rs.Produces)3 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)3 OperationResourceInfo (org.apache.cxf.jaxrs.model.OperationResourceInfo)3