Integration newIntegration(Step... steps) { for (int i = 0; i < steps.length; i++) { steps[i].getConnection().filter(r -> r.getId().isPresent()).ifPresent( resource -> this.put(resource.getId().get(), resource) ); steps[i].getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).filter(r -> r.getId().isPresent()).ifPresent( resource -> this.put(resource.getId().get(), resource) ); steps[i].getExtension().filter(r -> r.getId().isPresent()).ifPresent( resource -> this.put(resource.getId().get(), resource) ); steps[i] = new Step.Builder().createFrom(steps[i]).build(); } return new Integration.Builder() .id("test-integration") .name("Test Integration") .description("This is a test integration!") .addFlow(new Flow.Builder() .steps(Arrays.asList(steps)) .build()) .build(); } }
@Test public void shouldGenerateMessages() { final Step step = new Step.Builder().putConfiguredProperty("customText", "Log me baby one more time").build(); assertThat(LogStepHandler.createMessage(step)).isEqualTo("Log me baby one more time"); final Step withContext = new Step.Builder().createFrom(step) .putConfiguredProperty("contextLoggingEnabled", "true").build(); assertThat(LogStepHandler.createMessage(withContext)) .isEqualTo("Message Context: [${in.headers}] Log me baby one more time"); final Step withBody = new Step.Builder().createFrom(step).putConfiguredProperty("bodyLoggingEnabled", "true") .build(); assertThat(LogStepHandler.createMessage(withBody)).isEqualTo("Body: [${body}] Log me baby one more time"); final Step withContextAndBody = new Step.Builder().createFrom(step) .putConfiguredProperty("contextLoggingEnabled", "true").putConfiguredProperty("bodyLoggingEnabled", "true") .build(); assertThat(LogStepHandler.createMessage(withContextAndBody)) .isEqualTo("Message Context: [${in.headers}] Body: [${body}] Log me baby one more time"); }
.createFrom(sqlIntegration.getFlows().get(0).getSteps().get(0)) .connection(modSqlConnection) .build();
.createFrom(sqlIntegration.getFlows().get(0).getSteps().get(0)) .connection(modSqlConnection) .build();
/** * Creates an immutable copy of a {@link Step} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable Step instance */ public static Step copyOf(Step instance) { if (instance instanceof ImmutableStep) { return (ImmutableStep) instance; } return new Step.Builder() .createFrom(instance) .build(); }
protected static Integration newIntegration(Step... steps) { for (int i = 0; i < steps.length; i++) { steps[i] = new Step.Builder().createFrom(steps[i]).build(); } return new Integration.Builder() .id("test-integration") .name("Test Integration") .description("This is a test integration!") .addFlow(new Flow.Builder() .steps(Arrays.asList(steps)) .build()) .build(); }