use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.
the class ProjectGeneratorTest method testGenerateProject.
// ***************************
// Tests
// ***************************
@Test
public void testGenerateProject() throws Exception {
TestResourceManager resourceManager = new TestResourceManager();
Integration integration = resourceManager.newIntegration(new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().id("timer-connection").connector(TestConstants.TIMER_CONNECTOR).build()).putConfiguredProperty("period", "5000").action(TestConstants.PERIODIC_TIMER_ACTION).build(), new Step.Builder().stepKind(StepKind.mapper).putConfiguredProperty("atlasmapping", "{}").build(), new Step.Builder().stepKind(StepKind.ruleFilter).putConfiguredProperty("predicate", "AND").putConfiguredProperty("rules", "[{ \"path\": \"in.header.counter\", \"op\": \">\", \"value\": \"10\" }]").build(), new Step.Builder().stepKind(StepKind.extension).extension(new Extension.Builder().id("my-extension-1").extensionId("my-extension-1").addDependency(Dependency.maven("org.slf4j:slf4j-api:1.7.11")).addDependency(Dependency.maven("org.slf4j:slf4j-simple:1.7.11")).addDependency(Dependency.maven("org.apache.camel:camel-spring-boot-starter:2.10.0")).build()).putConfiguredProperty("key-1", "val-1").putConfiguredProperty("key-2", "val-2").action(new StepAction.Builder().id("my-extension-1-action-1").descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.ENDPOINT).entrypoint("direct:extension").build()).build()).build(), new Step.Builder().stepKind(StepKind.extension).extension(new Extension.Builder().id("my-extension-2").extensionId("my-extension-2").build()).putConfiguredProperty("key-1", "val-1").putConfiguredProperty("key-2", "val-2").action(new StepAction.Builder().id("my-extension-1-action-1").descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.BEAN).entrypoint("com.example.MyExtension::action").build()).build()).build(), new Step.Builder().stepKind(StepKind.extension).extension(new Extension.Builder().id("my-extension-3").extensionId("my-extension-3").build()).putConfiguredProperty("key-1", "val-1").putConfiguredProperty("key-2", "val-2").action(new StepAction.Builder().id("my-extension-2-action-1").descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.STEP).entrypoint("com.example.MyStep").build()).build()).build(), new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().id("http-connection").connector(TestConstants.HTTP_CONNECTOR).build()).putConfiguredProperty("httpUri", "http://localhost:8080/hello").putConfiguredProperty("username", "admin").putConfiguredProperty("password", "admin").putConfiguredProperty("token", "mytoken").action(TestConstants.HTTP_GET_ACTION).build());
ProjectGeneratorConfiguration configuration = new ProjectGeneratorConfiguration();
configuration.getTemplates().setOverridePath(this.basePath);
configuration.getTemplates().getAdditionalResources().addAll(this.additionalResources);
configuration.setSecretMaskingEnabled(true);
Path runtimeDir = generate(integration, configuration, resourceManager);
assertFileContents(configuration, runtimeDir.resolve("pom.xml"), "pom.xml");
assertFileContentsJson(configuration, runtimeDir.resolve("src/main/resources/syndesis/integration/integration.json"), "integration.json");
assertFileContents(configuration, runtimeDir.resolve("src/main/resources/application.properties"), "application.properties");
assertFileContents(configuration, runtimeDir.resolve("src/main/resources/loader.properties"), "loader.properties");
assertFileContents(configuration, runtimeDir.resolve(".s2i/bin/assemble"), "assemble");
assertFileContents(configuration, runtimeDir.resolve("prometheus-config.yml"), "prometheus-config.yml");
assertThat(runtimeDir.resolve("extensions/my-extension-1.jar")).exists();
assertThat(runtimeDir.resolve("extensions/my-extension-2.jar")).exists();
assertThat(runtimeDir.resolve("extensions/my-extension-3.jar")).exists();
assertThat(runtimeDir.resolve("src/main/resources/mapping-step-2.json")).exists();
}
use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.
the class NoDuplicateExtensionValidator method isValid.
@Override
public boolean isValid(final Extension value, final ConstraintValidatorContext context) {
if (value.getExtensionId() == null) {
return true;
}
Set<String> ids = dataManager.fetchIdsByPropertyValue(Extension.class, "extensionId", value.getExtensionId());
if (value.getId().isPresent()) {
ids.remove(value.getId().get());
}
for (String id : ids) {
Extension other = dataManager.fetch(Extension.class, id);
boolean installed = other.getStatus().isPresent() && other.getStatus().get() == Extension.Status.Installed;
if (installed) {
return false;
}
}
return true;
}
use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.
the class ExtensionActivator method doDelete.
private void doDelete(Extension extension) {
Date rightNow = new Date();
dataManager.update(new Extension.Builder().createFrom(extension).status(Extension.Status.Deleted).lastUpdated(rightNow).build());
}
use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.
the class ExtensionHandler method install.
@POST
@Path(value = "/{id}/install")
@ApiResponses({ @ApiResponse(code = 200, message = "Installed"), @ApiResponse(code = 400, message = "Found violations in validation", responseContainer = "Set", response = Violation.class) })
public void install(@NotNull @PathParam("id") final String id) {
Extension extension = getDataManager().fetch(Extension.class, id);
doValidate(extension);
extensionActivator.activateExtension(extension);
}
use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.
the class ExtensionsITCase method extensionData.
// ===========================================================
private byte[] extensionData(int prg) throws IOException {
try (ByteArrayOutputStream data = new ByteArrayOutputStream();
JarOutputStream jar = new JarOutputStream(data)) {
JarEntry definition = new JarEntry("META-INF/syndesis/syndesis-extension-definition.json");
jar.putNextEntry(definition);
Extension extension = new Extension.Builder().schemaVersion(ExtensionConverter.getCurrentSchemaVersion()).extensionId("com.company:extension" + prg).name("Extension " + prg).description("Extension Description " + prg).version("1.0").extensionType(Extension.Type.Steps).build();
JsonNode extensionTree = ExtensionConverter.getDefault().toPublicExtension(extension);
byte[] content = Json.writer().writeValueAsBytes(extensionTree);
IOUtils.write(content, jar);
jar.closeEntry();
jar.flush();
return data.toByteArray();
}
}
Aggregations