/** * Utility method to add a mock component location. * * @param component object to add the location. */ protected void addMockComponentLocation(Component component) { ComponentLocation componentLocation = mock(ComponentLocation.class, RETURNS_DEEP_STUBS); Mockito.when(componentLocation.getLineInFile()).thenReturn(empty()); Mockito.when(componentLocation.getFileName()).thenReturn(empty()); component.setAnnotations(Collections.singletonMap(LOCATION_KEY, componentLocation)); }
@Override public String getDescription() { ComponentLocation location = (ComponentLocation) getAnnotation(LOCATION_KEY); return format("<configuration-properties file=\"%s\"> - file: %s, line number: %s", fileLocation, location.getFileName().orElse(UNKNOWN), location.getLineInFile().map(String::valueOf).orElse("unknown")); }
@Override public String getDescription() { ComponentLocation location = (ComponentLocation) getAnnotation(LOCATION_KEY); return format("<secure-configuration-properties file=\"%s\"> - file: %s, line number: %s", fileLocation, location.getFileName().orElse(UNKNOWN), location.getLineInFile().map(String::valueOf).orElse("unknown")); }
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 configureProcessorLocation(Component component) { when(component.getLocation()).thenReturn(mockComponentLocation); when(mockComponentLocation.getFileName()).thenReturn(Optional.of("muleApp.xml")); when(mockComponentLocation.getLineInFile()).thenReturn(Optional.of(10)); } }
private void configureProcessorLocation(AnnotatedProcessor mockProcessor) { when(mockProcessor.getLocation()).thenReturn(mockComponentLocation); when(mockComponentLocation.getFileName()).thenReturn(Optional.of("muleApp.xml")); when(mockComponentLocation.getLineInFile()).thenReturn(Optional.of(10)); when(mockComponentLocation.getLocation()).thenReturn("Mock@1"); }
public Processor createMockProcessor(String processorPath, boolean useLocationSettings) { ComponentLocation componentLocation = mock(ComponentLocation.class); when(componentLocation.getLocation()).thenReturn(processorPath); when(componentLocation.getFileName()).thenReturn(useLocationSettings ? of(CONFIG_FILE_NAME) : empty()); when(componentLocation.getLineInFile()).thenReturn(useLocationSettings ? of(LINE_NUMBER) : empty()); Component annotatedMessageProcessor = (Component) mock(Processor.class, withSettings().extraInterfaces(Component.class).defaultAnswer(RETURNS_DEEP_STUBS)); when(annotatedMessageProcessor.getAnnotation(any())).thenReturn(null); when(annotatedMessageProcessor.getLocation()).thenReturn(componentLocation); return (Processor) annotatedMessageProcessor; }
@Before public void before() { manager = new MessageProcessingFlowTraceManager(); MuleContext context = mock(MuleContext.class); MuleConfiguration config = mock(MuleConfiguration.class); when(config.getId()).thenReturn(APP_ID); when(context.getConfiguration()).thenReturn(config); manager.setMuleContext(context); rootFlowConstruct = mock(FlowConstruct.class); ComponentLocation mockComponentLocation = mock(ComponentLocation.class); when(mockComponentLocation.getFileName()).thenReturn(of(CONFIG_FILE_NAME)); when(mockComponentLocation.getLineInFile()).thenReturn(of(LINE_NUMBER)); when(rootFlowConstruct.getLocation()).thenReturn(mockComponentLocation); when(rootFlowConstruct.getName()).thenReturn(ROOT_FLOW_NAME); when(rootFlowConstruct.getMuleContext()).thenReturn(context); nestedFlowConstruct = mock(FlowConstruct.class); when(nestedFlowConstruct.getLocation()).thenReturn(mockComponentLocation); when(nestedFlowConstruct.getName()).thenReturn(NESTED_FLOW_NAME); when(nestedFlowConstruct.getMuleContext()).thenReturn(context); messageContext = create(rootFlowConstruct, TEST_CONNECTOR_LOCATION); }
/** * Utility method to add a mock component location. * * @param component object to add the location. */ protected void addMockComponentLocation(Component component) { ComponentLocation componentLocation = mock(ComponentLocation.class, RETURNS_DEEP_STUBS); Mockito.when(componentLocation.getLineInFile()).thenReturn(empty()); Mockito.when(componentLocation.getFileName()).thenReturn(empty()); component.setAnnotations(Collections.singletonMap(LOCATION_KEY, componentLocation)); }
@Override public String getDescription() { ComponentLocation location = (ComponentLocation) getAnnotation(LOCATION_KEY); return format("<configuration-properties file=\"%s\"> - file: %s, line number: %s", fileLocation, location.getFileName().orElse(UNKNOWN), location.getLineInFile().map(String::valueOf).orElse("unknown")); }
@Override public String getDescription() { ComponentLocation location = (ComponentLocation) getAnnotation(LOCATION_KEY); return format("<secure-configuration-properties file=\"%s\"> - file: %s, line number: %s", fileLocation, location.getFileName().orElse(UNKNOWN), location.getLineInFile().map(String::valueOf).orElse("unknown")); }
private String locationToStringLog(ComponentLocation location) { return getIdentifier(location) + " in " + location.getFileName().orElse(" ? ") + "[line: " + location.getLineInFile().orElse(-1) + "]."; }
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) + "]."; }
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 configureProcessorLocation(AnnotatedProcessor mockProcessor) { when(mockProcessor.getLocation()).thenReturn(mockComponentLocation); when(mockComponentLocation.getFileName()).thenReturn(Optional.of("muleApp.xml")); when(mockComponentLocation.getLineInFile()).thenReturn(Optional.of(10)); when(mockComponentLocation.getLocation()).thenReturn("Mock@1"); }
private void configureProcessorLocation(Component component) { when(component.getLocation()).thenReturn(mockComponentLocation); when(mockComponentLocation.getFileName()).thenReturn(Optional.of("muleApp.xml")); when(mockComponentLocation.getLineInFile()).thenReturn(Optional.of(10)); when(mockComponentLocation.getLocation()).thenReturn("Mock@1"); } }
public Processor createMockProcessor(String processorPath, boolean useLocationSettings) { ComponentLocation componentLocation = mock(ComponentLocation.class); when(componentLocation.getLocation()).thenReturn(processorPath); when(componentLocation.getFileName()).thenReturn(useLocationSettings ? of(CONFIG_FILE_NAME) : empty()); when(componentLocation.getLineInFile()).thenReturn(useLocationSettings ? of(LINE_NUMBER) : empty()); Component annotatedMessageProcessor = (Component) mock(Processor.class, withSettings().extraInterfaces(Component.class).defaultAnswer(RETURNS_DEEP_STUBS)); when(annotatedMessageProcessor.getAnnotation(any())).thenReturn(null); when(annotatedMessageProcessor.getLocation()).thenReturn(componentLocation); return (Processor) annotatedMessageProcessor; }
@Before public void before() { manager = new MessageProcessingFlowTraceManager(); MuleContext context = mock(MuleContext.class); MuleConfiguration config = mock(MuleConfiguration.class); when(config.getId()).thenReturn(APP_ID); when(context.getConfiguration()).thenReturn(config); manager.setMuleContext(context); rootFlowConstruct = mock(FlowConstruct.class); ComponentLocation mockComponentLocation = mock(ComponentLocation.class); when(mockComponentLocation.getFileName()).thenReturn(of(CONFIG_FILE_NAME)); when(mockComponentLocation.getLineInFile()).thenReturn(of(LINE_NUMBER)); when(rootFlowConstruct.getLocation()).thenReturn(mockComponentLocation); when(rootFlowConstruct.getName()).thenReturn(ROOT_FLOW_NAME); when(rootFlowConstruct.getMuleContext()).thenReturn(context); nestedFlowConstruct = mock(FlowConstruct.class); when(nestedFlowConstruct.getLocation()).thenReturn(mockComponentLocation); when(nestedFlowConstruct.getName()).thenReturn(NESTED_FLOW_NAME); when(nestedFlowConstruct.getMuleContext()).thenReturn(context); messageContext = create(rootFlowConstruct, TEST_CONNECTOR_LOCATION); }