use of org.apache.nifi.web.ComponentDetails in project nifi by apache.
the class ProcessorResource method getDetails.
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("/details")
public Response getDetails(@QueryParam("processorId") final String processorId) {
final NiFiWebConfigurationContext nifiWebContext = getWebConfigurationContext();
final ComponentDetails componentDetails = ProcessorWebUtils.getComponentDetails(nifiWebContext, processorId, request);
final Response.ResponseBuilder response = ProcessorWebUtils.applyCacheControl(Response.ok(componentDetails));
return response.build();
}
use of org.apache.nifi.web.ComponentDetails in project nifi by apache.
the class TestProcessorResource method testSetProperties.
@Test
public void testSetProperties() {
final NiFiWebConfigurationContext niFiWebConfigurationContext = mock(NiFiWebConfigurationContext.class);
final Map<String, String> properties = new HashMap<>();
properties.put("jolt-transform", "jolt-transform-chain");
final ComponentDetails componentDetails = new ComponentDetails.Builder().properties(properties).build();
Mockito.when(servletContext.getAttribute(Mockito.anyString())).thenReturn(niFiWebConfigurationContext);
Mockito.when(niFiWebConfigurationContext.updateComponent(any(NiFiWebConfigurationRequestContext.class), any(String.class), any(Map.class))).thenReturn(componentDetails);
Response response = client().target(getBaseUri()).path("/standard/processor/properties").queryParam("processorId", "1").queryParam("clientId", "1").queryParam("revisionId", "1").request().put(Entity.json(JsonUtils.toJsonString(properties)));
assertNotNull(response);
JsonNode jsonNode = response.readEntity(JsonNode.class);
assertNotNull(jsonNode);
assertTrue(jsonNode.get("properties").get("jolt-transform").asText().equals("jolt-transform-chain"));
}
use of org.apache.nifi.web.ComponentDetails in project nifi by apache.
the class TestProcessorResource method testGetProcessorDetails.
@Test
public void testGetProcessorDetails() {
final NiFiWebConfigurationContext niFiWebConfigurationContext = mock(NiFiWebConfigurationContext.class);
final Map<String, String> allowableValues = new HashMap<>();
final ComponentDescriptor descriptor = new ComponentDescriptor.Builder().name("test-name").allowableValues(allowableValues).build();
final Map<String, ComponentDescriptor> descriptors = new HashMap<>();
descriptors.put("jolt-transform", descriptor);
final ComponentDetails componentDetails = new ComponentDetails.Builder().name("mytransform").type("org.apache.nifi.processors.standard.JoltTransformJSON").descriptors(descriptors).build();
Mockito.when(servletContext.getAttribute(Mockito.anyString())).thenReturn(niFiWebConfigurationContext);
Mockito.when(niFiWebConfigurationContext.getComponentDetails(any(NiFiWebRequestContext.class))).thenReturn(componentDetails);
JsonNode value = client().target(getBaseUri()).path("/standard/processor/details").queryParam("processorId", "1").request().get(JsonNode.class);
assertNotNull(value);
try {
assertTrue(value.get("name").asText().equals("mytransform"));
} catch (Exception e) {
fail("Failed due to: " + e.toString());
}
}
use of org.apache.nifi.web.ComponentDetails in project nifi by apache.
the class TestTransformJSONResource method testValidateWithCustomSpec.
@Test
public void testValidateWithCustomSpec() {
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());
}
use of org.apache.nifi.web.ComponentDetails in project nifi by apache.
the class TestTransformJSONResource method testValidateWithInvalidSpec.
@Test
public void testValidateWithInvalidSpec() {
final NiFiWebConfigurationContext niFiWebConfigurationContext = mock(NiFiWebConfigurationContext.class);
final Map<String, String> properties = new HashMap<>();
properties.put("jolt-transform", "jolt-transform-chain");
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-chain", "[]");
ValidationDTO validate = client().target(getBaseUri()).path("/standard/transformjson/validate").request().post(Entity.json(joltSpecificationDTO), ValidationDTO.class);
assertNotNull(validate);
assertTrue(!validate.isValid());
}
Aggregations