use of io.kaoto.backend.model.step.Step in project kaoto-backend by KaotoIO.
the class KameletParseCatalogTest method getSteps.
@Test
void getSteps() {
ParseCatalog<Step> kameletParser = parseCatalog.getParser("https://github.com/apache/camel-kamelets.git", "v0.5.0");
InMemoryCatalog<Step> catalog = new InMemoryCatalog<>();
List<Step> steps = kameletParser.parse().join();
assertTrue(catalog.store(steps));
assertEquals(catalog.getAll().size(), steps.size());
String name = "ftp-source";
String[] required = new String[] { "connectionHost", "connectionPort", "username", "password", "directoryName" };
Step step = catalog.searchStepByName(name);
assertEquals(step.getRequired().size(), required.length);
assertTrue(Arrays.stream(required).allMatch(property -> step.getRequired().contains(property)));
Assertions.assertNotNull(step);
assertEquals(name, step.getId());
assertEquals(name, step.getName());
assertEquals("Kamelet", step.getKind());
assertEquals("START", step.getType());
Assertions.assertNotNull(step.getParameters());
assertEquals(8, step.getParameters().size());
for (var p : step.getParameters()) {
Assertions.assertNotNull(p.getType());
Assertions.assertNotNull(p.getTitle());
Assertions.assertNotNull(p.getId());
Assertions.assertNotNull(p.getType());
Assertions.assertNotNull(p.getDescription());
}
}
use of io.kaoto.backend.model.step.Step in project kaoto-backend by KaotoIO.
the class DeploymentService method crd.
/*
* 🐱method yaml: String
* 🐱param steps: List[Step]
* 🐱param name: String
*
* Based on the provided steps, return a valid yaml string to deploy
*/
public Map<String, String> crd(final String name, final Step[] stepArray) {
List<Step> steps = Arrays.asList(stepArray);
Map<String, String> strings = new HashMap<>();
Map<String, Object> metadata = new HashMap<>();
metadata.put("name", name);
for (DeploymentGeneratorService parser : getParsers()) {
try {
if (parser.appliesTo(steps)) {
strings.put(parser.identifier(), parser.parse(steps, metadata));
}
} catch (Exception e) {
log.warn("Parser " + parser.getClass() + "threw an unexpected" + " error. ", e);
}
}
return strings;
}
use of io.kaoto.backend.model.step.Step in project kaoto-backend by KaotoIO.
the class KameletBindingDeploymentGeneratorService method parse.
@Override
public String parse(final List<Step> steps, final Map<String, Object> metadata) {
if (!appliesTo(steps)) {
return "";
}
KameletBindingSpec spec = new KameletBindingSpec();
int i = 0;
if (!steps.isEmpty()) {
Step step = steps.get(i);
if ("START".equalsIgnoreCase(step.getType())) {
spec.setSource(createKameletBindingStep(steps.get(i++)));
}
}
for (; i < steps.size() - 1; i++) {
spec.getSteps().add(createKameletBindingStep(steps.get(i)));
}
if (spec.getSteps().isEmpty()) {
spec.setSteps(null);
}
if (steps.size() > 1) {
spec.setSink(createKameletBindingStep(steps.get(steps.size() - 1)));
}
KameletBinding binding = new KameletBinding(String.valueOf(metadata.getOrDefault("name", "")), spec);
Yaml yaml = new Yaml(new Constructor(KameletBinding.class), new KameletRepresenter());
return yaml.dumpAsMap(binding);
}
use of io.kaoto.backend.model.step.Step in project kaoto-backend by KaotoIO.
the class CatalogCollectionTest method before.
@BeforeAll
static void before() {
List<Step> steps = new ArrayList<>();
InMemoryCatalog<Step> ic = new InMemoryCatalog<>();
steps.add(new Step("id-1", "connector-1", "icon", Collections.emptyList()));
steps.add(new Step("id-2", CONNECTOR_2, "icon", Collections.emptyList()));
ic.store(steps);
catalogCollection.addCatalog(ic);
ic = new InMemoryCatalog<>();
steps.clear();
steps.add(new Step("id-2", CONNECTOR_2, "icon", Collections.emptyList()));
steps.add(new Step("id-3", CONNECTOR_2, "icon", Collections.emptyList()));
ic.store(steps);
catalogCollection.addCatalog(ic);
}
use of io.kaoto.backend.model.step.Step in project kaoto-backend by KaotoIO.
the class CatalogCollectionTest method searchStepByName.
@Test
void searchStepByName() {
Step step = catalogCollection.searchStepByName(CONNECTOR_2);
Assertions.assertNotNull(step);
Assertions.assertEquals(CONNECTOR_2, step.getName());
}
Aggregations