use of io.kestra.core.models.templates.Template in project kestra by kestra-io.
the class MemoryTemplateRepository method findDistinctNamespace.
@Override
public List<String> findDistinctNamespace() {
HashSet<String> namespaces = new HashSet<>();
for (Template t : this.findAll()) {
namespaces.add(t.getNamespace());
}
ArrayList<String> namespacesList = new ArrayList<>(namespaces);
Collections.sort(namespacesList);
return new ArrayList<>(namespacesList);
}
use of io.kestra.core.models.templates.Template in project kestra by kestra-io.
the class TemplateControllerTest method updateTemplate.
@Test
void updateTemplate() {
Template template = createTemplate();
client.toBlocking().retrieve(POST("/api/v1/templates", template), Template.class);
Template createdTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class);
assertThat(template.getTasks().size(), is(2));
Task t3 = Return.builder().id("task-3").type(Return.class.getName()).format("test").build();
Template updateTemplate = Template.builder().id(template.getId()).namespace(template.getNamespace()).tasks(Arrays.asList(t3)).build();
client.toBlocking().retrieve(PUT("/api/v1/templates/" + template.getNamespace() + "/" + template.getId(), updateTemplate), Template.class);
Template updatedTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class);
assertThat(updatedTemplate.getTasks().size(), is(1));
assertThat(updatedTemplate.getTasks().get(0).getId(), is("task-3"));
}
use of io.kestra.core.models.templates.Template in project kestra by kestra-io.
the class TemplateControllerTest method deleteTemplate.
@Test
void deleteTemplate() {
Template template = createTemplate();
client.toBlocking().retrieve(POST("/api/v1/templates", template), Template.class);
Template createdTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class);
assertThat(createdTemplate.getId(), is(template.getId()));
HttpResponse<Void> deleteResult = client.toBlocking().exchange(DELETE("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()));
assertThat(deleteResult.getStatus(), is(NO_CONTENT));
HttpClientResponseException e = assertThrows(HttpClientResponseException.class, () -> {
client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()));
});
assertThat(e.getStatus(), is(HttpStatus.NOT_FOUND));
}
use of io.kestra.core.models.templates.Template in project kestra by kestra-io.
the class TemplateControllerTest method create.
@Test
void create() {
Template template = createTemplate();
HttpClientResponseException e = assertThrows(HttpClientResponseException.class, () -> {
client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getId()));
});
assertThat(e.getStatus(), is(HttpStatus.NOT_FOUND));
Template result = client.toBlocking().retrieve(POST("/api/v1/templates", template), Template.class);
Template createdTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class);
assertThat(createdTemplate.getId(), is(template.getId()));
}
use of io.kestra.core.models.templates.Template in project kestra by kestra-io.
the class AbstractTemplateRepositoryTest method findAll.
@Test
void findAll() {
long saveCount = templateRepository.findAll().size();
Template template = builder().build();
templateRepository.create(template);
long size = templateRepository.findAll().size();
assertThat(size, greaterThan(saveCount));
templateRepository.delete(template);
assertThat((long) templateRepository.findAll().size(), is(saveCount));
}
Aggregations