Search in sources :

Example 6 with Template

use of io.kestra.core.models.templates.Template in project kestra by kestra-io.

the class AbstractTemplateRepositoryTest method delete.

@Test
void delete() {
    Template template = builder().build();
    Template save = templateRepository.create(template);
    templateRepository.delete(save);
    assertThat(templateRepository.findById(template.getNamespace(), template.getId()).isPresent(), is(false));
    assertThat(TemplateListener.getEmits().size(), is(2));
    assertThat(TemplateListener.getEmits().stream().filter(r -> r.getType() == CrudEventType.CREATE).count(), is(1L));
    assertThat(TemplateListener.getEmits().stream().filter(r -> r.getType() == CrudEventType.DELETE).count(), is(1L));
}
Also used : Template(io.kestra.core.models.templates.Template) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 7 with Template

use of io.kestra.core.models.templates.Template in project kestra by kestra-io.

the class RestoreQueueService method templates.

public int templates(boolean noRecreate) {
    TemplateRepositoryInterface templateRepository = applicationContext.getBean(TemplateRepositoryInterface.class);
    List<Template> templates = new ArrayList<>(templateRepository.findAll());
    return this.send(templates, QueueFactoryInterface.TEMPLATE_NAMED, Template.class, noRecreate);
}
Also used : TemplateRepositoryInterface(io.kestra.core.repositories.TemplateRepositoryInterface) ArrayList(java.util.ArrayList) Template(io.kestra.core.models.templates.Template)

Example 8 with Template

use of io.kestra.core.models.templates.Template in project kestra by kestra-io.

the class AbstractTemplateRepositoryTest method save.

@Test
void save() {
    Template template = builder().build();
    Template save = templateRepository.create(template);
    assertThat(save.getId(), is(template.getId()));
}
Also used : Template(io.kestra.core.models.templates.Template) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 9 with Template

use of io.kestra.core.models.templates.Template in project kestra by kestra-io.

the class AbstractTemplateRepositoryTest method findByNamespace.

@Test
void findByNamespace() {
    Template template1 = builder().build();
    Template template2 = Template.builder().id(IdUtils.create()).namespace("kestra.test.template").build();
    templateRepository.create(template1);
    templateRepository.create(template2);
    List<Template> templates = templateRepository.findByNamespace(template1.getNamespace());
    assertThat(templates.size(), greaterThanOrEqualTo(1));
    templates = templateRepository.findByNamespace(template2.getNamespace());
    assertThat(templates.size(), is(1));
}
Also used : Template(io.kestra.core.models.templates.Template) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 10 with Template

use of io.kestra.core.models.templates.Template in project kestra by kestra-io.

the class AbstractTemplateRepositoryTest method findById.

@Test
void findById() {
    Template template = builder().build();
    templateRepository.create(template);
    Optional<Template> full = templateRepository.findById(template.getNamespace(), template.getId());
    assertThat(full.isPresent(), is(true));
    full.ifPresent(current -> {
        assertThat(full.get().getId(), is(template.getId()));
    });
}
Also used : Template(io.kestra.core.models.templates.Template) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Aggregations

Template (io.kestra.core.models.templates.Template)12 Test (org.junit.jupiter.api.Test)9 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)5 AbstractMemoryRunnerTest (io.kestra.core.runners.AbstractMemoryRunnerTest)4 HttpClientResponseException (io.micronaut.http.client.exceptions.HttpClientResponseException)2 Task (io.kestra.core.models.tasks.Task)1 TemplateRepositoryInterface (io.kestra.core.repositories.TemplateRepositoryInterface)1 Return (io.kestra.core.tasks.debugs.Return)1 ArrayList (java.util.ArrayList)1 BoolQueryBuilder (org.opensearch.index.query.BoolQueryBuilder)1 SearchSourceBuilder (org.opensearch.search.builder.SearchSourceBuilder)1