Search in sources :

Example 11 with ComponentDetails

use of org.apache.nifi.web.ComponentDetails in project nifi by apache.

the class TestTransformJSONResource method testValidateWithCustomInvalidSpec.

@Test
public void testValidateWithCustomInvalidSpec() {
    final NiFiWebConfigurationContext niFiWebConfigurationContext = mock(NiFiWebConfigurationContext.class);
    final Map<String, String> properties = new HashMap<>();
    properties.put("jolt-transform", "jolt-transform-custom");
    final ComponentDetails componentDetails = new ComponentDetails.Builder().properties(properties).build();
    Mockito.when(servletContext.getAttribute(Mockito.anyString())).thenReturn(niFiWebConfigurationContext);
    Mockito.when(niFiWebConfigurationContext.getComponentDetails(any(NiFiWebRequestContext.class))).thenReturn(componentDetails);
    JoltSpecificationDTO joltSpecificationDTO = new JoltSpecificationDTO("jolt-transform-custom", "{ \"operation\": \"default\", \"spec\":{ \"custom-id\" :4 }}");
    joltSpecificationDTO.setCustomClass("TestCustomJoltTransform");
    joltSpecificationDTO.setModules("src/test/resources/TestTransformJSONResource/TestCustomJoltTransform.jar");
    ValidationDTO validate = client().target(getBaseUri()).path("/standard/transformjson/validate").request().post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
    assertNotNull(validate);
    assertTrue(!validate.isValid());
}
Also used : HashMap(java.util.HashMap) JoltSpecificationDTO(org.apache.nifi.web.standard.api.transformjson.dto.JoltSpecificationDTO) ValidationDTO(org.apache.nifi.web.standard.api.transformjson.dto.ValidationDTO) NiFiWebConfigurationContext(org.apache.nifi.web.NiFiWebConfigurationContext) ComponentDetails(org.apache.nifi.web.ComponentDetails) NiFiWebRequestContext(org.apache.nifi.web.NiFiWebRequestContext) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Aggregations

ComponentDetails (org.apache.nifi.web.ComponentDetails)11 NiFiWebConfigurationContext (org.apache.nifi.web.NiFiWebConfigurationContext)10 Test (org.junit.Test)8 HashMap (java.util.HashMap)6 JerseyTest (org.glassfish.jersey.test.JerseyTest)6 NiFiWebRequestContext (org.apache.nifi.web.NiFiWebRequestContext)5 JoltSpecificationDTO (org.apache.nifi.web.standard.api.transformjson.dto.JoltSpecificationDTO)4 ValidationDTO (org.apache.nifi.web.standard.api.transformjson.dto.ValidationDTO)4 Response (javax.ws.rs.core.Response)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 NiFiWebConfigurationRequestContext (org.apache.nifi.web.NiFiWebConfigurationRequestContext)2 Map (java.util.Map)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 NotFoundException (javax.ws.rs.NotFoundException)1 PUT (javax.ws.rs.PUT)1 WebApplicationException (javax.ws.rs.WebApplicationException)1