Search in sources :

Example 1 with StringBeginsWith

use of com.redhat.service.smartevents.infra.models.filters.StringBeginsWith in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class FilterEvaluatorFactoryFEELTest method testStringBeginsWithTemplate.

@Test
public void testStringBeginsWithTemplate() {
    String expectedSingle = "if (starts with (data.name, \"jrota\")) then \"OK\" else \"NOT_OK\"";
    String templateSingle = TEMPLATE_FACTORY_FEEL.getTemplateByFilterType(new StringBeginsWith("data.name", Arrays.asList("jrota")));
    assertThat(templateSingle).isEqualTo(expectedSingle);
    String expectedMulti = "if (starts with (data.name, \"jacopo\")) or (starts with (data.name, \"rota\")) then \"OK\" else \"NOT_OK\"";
    String templateMulti = TEMPLATE_FACTORY_FEEL.getTemplateByFilterType(new StringBeginsWith("data.name", Arrays.asList("jacopo", "rota")));
    assertThat(templateMulti).isEqualTo(expectedMulti);
}
Also used : StringBeginsWith(com.redhat.service.smartevents.infra.models.filters.StringBeginsWith) Test(org.junit.jupiter.api.Test)

Example 2 with StringBeginsWith

use of com.redhat.service.smartevents.infra.models.filters.StringBeginsWith in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method testUpdateProcessorWithNoChange.

@ParameterizedTest
@MethodSource("updateProcessorParams")
void testUpdateProcessorWithNoChange(ProcessorRequest request) {
    Set<BaseFilter> filters = Set.of(new StringBeginsWith("source", List.of("Storage")), new StringContains("source", List.of("StorageService")), new StringEquals("source", "StorageService"), new StringIn("source", List.of("StorageService")));
    request.setFilters(filters);
    Processor existingProcessor = createReadyProcessorFromRequest(request);
    when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(existingProcessor);
    Processor updatedProcessor = processorService.updateProcessor(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID, request);
    assertThat(updatedProcessor.getStatus()).isEqualTo(READY);
    assertThat(updatedProcessor).isEqualTo(existingProcessor);
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) Processor(com.redhat.service.smartevents.manager.models.Processor) StringBeginsWith(com.redhat.service.smartevents.infra.models.filters.StringBeginsWith) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) StringIn(com.redhat.service.smartevents.infra.models.filters.StringIn) StringContains(com.redhat.service.smartevents.infra.models.filters.StringContains) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

StringBeginsWith (com.redhat.service.smartevents.infra.models.filters.StringBeginsWith)2 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)1 StringContains (com.redhat.service.smartevents.infra.models.filters.StringContains)1 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)1 StringIn (com.redhat.service.smartevents.infra.models.filters.StringIn)1 Processor (com.redhat.service.smartevents.manager.models.Processor)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1