use of org.apache.nifi.web.ComponentDetails in project nifi by apache.
the class TestTransformJSONResource method testValidateWithCustomSpecEmptyModule.
@Test
public void testValidateWithCustomSpecEmptyModule() {
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");
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 ProcessorResource method setProperties.
@PUT
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
@Path("/properties")
public Response setProperties(@QueryParam("processorId") final String processorId, @QueryParam("revisionId") final Long revisionId, @QueryParam("clientId") final String clientId, Map<String, String> properties) {
final NiFiWebConfigurationContext nifiWebContext = getWebConfigurationContext();
final NiFiWebConfigurationRequestContext niFiRequestContext = ProcessorWebUtils.getRequestContext(processorId, revisionId, clientId, request);
final ComponentDetails componentDetails = nifiWebContext.updateComponent(niFiRequestContext, null, properties);
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 TestProcessorWebUtils method testGetComponentDetailsForProcessor.
@Test
public void testGetComponentDetailsForProcessor() {
HttpServletRequest request = mock(HttpServletRequest.class);
NiFiWebConfigurationContext configurationContext = mock(NiFiWebConfigurationContext.class);
when(configurationContext.getComponentDetails(any(HttpServletRequestContext.class))).thenReturn(new ComponentDetails.Builder().build());
ComponentDetails componentDetails = ProcessorWebUtils.getComponentDetails(configurationContext, "1", request);
assertNotNull(componentDetails);
}
use of org.apache.nifi.web.ComponentDetails in project nifi by apache.
the class TestProcessorWebUtils method testGetComponentDetailsForProcessorWithSpecificClientRevision.
@Test
public void testGetComponentDetailsForProcessorWithSpecificClientRevision() {
NiFiWebConfigurationContext configurationContext = mock(NiFiWebConfigurationContext.class);
when(configurationContext.getComponentDetails(any(HttpServletConfigurationRequestContext.class))).thenReturn(new ComponentDetails.Builder().build());
ComponentDetails componentDetails = ProcessorWebUtils.getComponentDetails(configurationContext, "1", 1L, "client1", mock(HttpServletRequest.class));
assertNotNull(componentDetails);
}
use of org.apache.nifi.web.ComponentDetails in project nifi by apache.
the class RuleResource method getCriteria.
private Criteria getCriteria(final NiFiWebConfigurationContext configurationContext, final NiFiWebRequestContext requestContext) {
final ComponentDetails processorDetails;
try {
// load the processor configuration
processorDetails = configurationContext.getComponentDetails(requestContext);
} catch (final InvalidRevisionException ire) {
throw new WebApplicationException(ire, invalidRevision(ire.getMessage()));
} catch (final Exception e) {
final String message = String.format("Unable to get UpdateAttribute[id=%s] criteria: %s", requestContext.getId(), e);
logger.error(message, e);
throw new WebApplicationException(e, error(message));
}
Criteria criteria = null;
if (processorDetails != null) {
try {
criteria = CriteriaSerDe.deserialize(processorDetails.getAnnotationData());
} catch (final IllegalArgumentException iae) {
final String message = String.format("Unable to deserialize existing rules for UpdateAttribute[id=%s]. Deserialization error: %s", requestContext.getId(), iae);
logger.error(message, iae);
throw new WebApplicationException(iae, error(message));
}
}
// ensure the criteria isn't null
if (criteria == null) {
criteria = new Criteria();
}
return criteria;
}
Aggregations