/** * {@inheritDoc} */ @Override public List<Component> find(ComponentIdentifier componentIdentifier) { return componentsMap.values().stream() .filter(component -> component.getLocation().getComponentIdentifier().getIdentifier().equals(componentIdentifier)) .collect(toList()); }
@Override public boolean mustStartMessageSource(Component component) { if (configurationProperties.resolveProperty(DISABLE_SCHEDULER_SOURCES_PROPERTY).isPresent()) { if (component.getLocation().getComponentIdentifier().getIdentifier().equals(SCHEDULER_MESSAGE_SOURCE_IDENTIFIER)) { return !configurationProperties.resolveBooleanProperty(DISABLE_SCHEDULER_SOURCES_PROPERTY).orElse(false); } } return true; }
@Override public Action getAction() { if (action == null) { action = new ExtensionAction(component.getLocation().getComponentIdentifier().getIdentifier().getNamespace().toUpperCase(), ((Enum) actionDefinition).name()); } return action; }
private Exception handleMissingRequiredParameter(RequiredParameterNotSetException e) { String description = getAnnotations().values().stream() .filter(v -> v instanceof ComponentLocation) .map(v -> (ComponentLocation) v) .findFirst() .map(v -> format("Element <%s:%s> in line %s of file %s is missing required parameter '%s'", v.getComponentIdentifier().getIdentifier().getNamespace(), v.getComponentIdentifier().getIdentifier().getName(), v.getLineInFile().map(n -> "" + n).orElse("<UNKNOWN>"), v.getFileName().orElse("<UNKNOWN>"), hyphenize(e.getParameterName()))) .orElse(e.getMessage()); return new ConfigurationException(createStaticMessage(description), e); }
private void mockComponent() { component = mock(Component.class, RETURNS_DEEP_STUBS); identifier = mock(ComponentIdentifier.class); when(component.getLocation().getComponentIdentifier().getIdentifier()).thenReturn(identifier); }
@Test @Description("Verify that a location produces connector and source data.") public void componentData() throws Exception { TypedComponentIdentifier typedComponentIdentifier = TypedComponentIdentifier.builder() .type(SOURCE) .identifier(buildFromStringRepresentation("http:listener")) .build(); ComponentLocation location = mock(ComponentLocation.class); when(location.getComponentIdentifier()).thenReturn(typedComponentIdentifier); when(location.getParts()).thenReturn(asList(new DefaultLocationPart("flow", empty(), empty(), empty(), empty()))); BaseEventContext context = contextWithComponentLocation.apply(location); assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getNamespace(), is("http")); assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getName(), is("listener")); }
@Test public void fireNotificationUsingLocation() { final LocationPart flowPart = mock(LocationPart.class); when(flowPart.getPartPath()).thenReturn("flowName"); final ComponentLocation location = mock(ComponentLocation.class); when(location.getParts()).thenReturn(Collections.singletonList(flowPart)); when(location.getComponentIdentifier()).thenReturn(TypedComponentIdentifier.builder() .type(SOURCE) .identifier(buildFromStringRepresentation("http:listener")) .build()); when(messageSource.getLocation()).thenReturn(location); final FlowConstruct flowConstruct = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class)); when(flowConstruct.getMuleContext()).thenReturn(muleContext); final int action = 100; helper.fireNotification(messageSource, event, location, action); assertConnectorMessageNotification(eventNotificationHandler, messageSource, location, action); }
@Test @Description("Verify that a single component location produces connector and source data.") public void componentDataFromSingleComponent() throws Exception { BaseEventContext context = this.context.get(); assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getNamespace(), is(CORE_PREFIX)); assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getName(), is("test")); }
/** * {@inheritDoc} */ @Override public List<Component> find(ComponentIdentifier componentIdentifier) { return componentsMap.values().stream() .filter(component -> component.getLocation().getComponentIdentifier().getIdentifier().equals(componentIdentifier)) .collect(toList()); }
private boolean isBehaviorValidForCoreOperations(MockBehavior behavior, String baseErrorMessage) { if ("set-payload".equals(location.getComponentIdentifier().getIdentifier().toString())) { return isBehaviorValidForSetPayload(behavior, baseErrorMessage); } if ("set-variable".equals(location.getComponentIdentifier().getIdentifier().toString())) { return isBehaviorValidForSetVariable(behavior, baseErrorMessage); } return true; }
public String getBaseErrorMessage() { String identifier = location.getComponentIdentifier().getIdentifier().toString(); String baseErrorMessage = "You have defined a behavior for " + identifier + " in " + location.getFileName().orElse(" ? ") + "[line: " + location.getLineInFile().orElse(-1) + "]."; return baseErrorMessage; }
private String locationToStringLog(ComponentLocation location) { return location.getComponentIdentifier().getIdentifier() + " in " + location.getFileName().orElse(" ? ") + "[line: " + location.getLineInFile().orElse(-1) + "]."; }
private String locationToStringLog(ComponentLocation location) { return location.getComponentIdentifier().getIdentifier() + " in " + location.getFileName().orElse(" ? ") + "[line: " + location.getLineInFile().orElse(-1) + "]."; }
@Override public boolean mustStartMessageSource(Component component) { if (configurationProperties.resolveProperty(DISABLE_SCHEDULER_SOURCES_PROPERTY).isPresent()) { if (component.getLocation().getComponentIdentifier().getIdentifier().equals(SCHEDULER_MESSAGE_SOURCE_IDENTIFIER)) { return !configurationProperties.resolveBooleanProperty(DISABLE_SCHEDULER_SOURCES_PROPERTY).orElse(false); } } return true; }
public CredentialsNotSetException(CoreEvent event, SecurityContext context, SecurityFilter filter) { super(context, filter.getClass().getName(), event.getContext().getOriginatingLocation().getComponentIdentifier().getIdentifier().getNamespace()); } }
@Override public Action getAction() { if (action == null) { action = new ExtensionAction(component.getLocation().getComponentIdentifier().getIdentifier().getNamespace().toUpperCase(), ((Enum) actionDefinition).name()); } return action; }
@Override public boolean intercept(ComponentLocation location) { TypedComponentIdentifier identifier = location.getComponentIdentifier(); if (NON_INTERCEPTABLE_NAMESPACES.contains(identifier.getIdentifier().getNamespace())) { return false; } if (!OPERATION.equals(identifier.getType())) { return false; } if (isInsideMunitToolsSpy(location)) { return false; } return true; }
private PolicyPointcutParameters createOperationPointcutParameters(Component operation, Map<String, Object> operationParameters) { ComponentIdentifier operationIdentifier = operation.getLocation().getComponentIdentifier().getIdentifier(); return createPointcutParameters(operation, OperationPolicyPointcutParametersFactory.class, operationPointcutFactories, factory -> factory.supportsOperationIdentifier(operationIdentifier), factory -> factory.createPolicyPointcutParameters(operation, operationParameters)); }
private PolicyPointcutParameters createSourcePointcutParameters(Component source, CoreEvent sourceEvent) { ComponentIdentifier sourceIdentifier = source.getLocation().getComponentIdentifier().getIdentifier(); return createPointcutParameters(source, SourcePolicyPointcutParametersFactory.class, sourcePointcutFactories, factory -> factory.supportsSourceIdentifier(sourceIdentifier), factory -> factory.createPolicyPointcutParameters(source, sourceEvent.getMessage().getAttributes())); }
@Test @Description("Verify that a single component location produces connector and source data.") public void componentDataFromSingleComponent() throws Exception { BaseEventContext context = this.context.get(); assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getNamespace(), is(CORE_PREFIX)); assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getName(), is("test")); }