Search in sources :

Example 1 with ConnectorTypology

use of org.talend.components.service.rest.dto.ConnectorTypology in project components by Talend.

the class DefinitionsControllerTest method shouldFilterComponentsByTypologyAndExecutionEngine.

public void shouldFilterComponentsByTypologyAndExecutionEngine(ConnectorTypology wantedTypology, ExecutionEngine executionEngine, int expectedResults) throws IOException {
    // given
    Map<String, ComponentDefinition> definitions = getComponentsDefinitions();
    // 
    BDDMockito.given(delegate.getDefinitionsMapByType(ComponentDefinition.class)).willReturn(definitions);
    // when
    final Response response = when().get(getVersionPrefix() + "/definitions/components?typology=" + wantedTypology + "&executionEngine=" + executionEngine.name()).andReturn();
    // then
    assertEquals(OK.value(), response.getStatusCode());
    List<DefinitionDTO> actual = objectMapper.readValue(response.asInputStream(), new TypeReference<List<DefinitionDTO>>() {
    });
    assertEquals(expectedResults, actual.size());
    assertEquals(expectedResults, actual.stream().filter(dto -> dto.getTypologies().contains(wantedTypology.name())).filter(dto -> dto.getExecutionEngines().contains(executionEngine.name())).count());
}
Also used : Response(com.jayway.restassured.response.Response) DefinitionsController(org.talend.components.service.rest.DefinitionsController) MockComponentDefinition(org.talend.components.service.rest.mock.MockComponentDefinition) Autowired(org.springframework.beans.factory.annotation.Autowired) DATA_STORE(org.talend.components.service.rest.DefinitionType.DATA_STORE) HashMap(java.util.HashMap) Definition(org.talend.daikon.definition.Definition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) NONE(org.talend.components.api.component.ConnectorTopology.NONE) Function(java.util.function.Function) ExecutionEngine(org.talend.components.api.component.runtime.ExecutionEngine) Response(com.jayway.restassured.response.Response) OUTGOING(org.talend.components.api.component.ConnectorTopology.OUTGOING) TRANSFORMER(org.talend.components.service.rest.dto.ConnectorTypology.TRANSFORMER) SOURCE(org.talend.components.service.rest.dto.ConnectorTypology.SOURCE) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Matchers.hasSize(org.hamcrest.Matchers.hasSize) INCOMING_AND_OUTGOING(org.talend.components.api.component.ConnectorTopology.INCOMING_AND_OUTGOING) TypeReference(com.fasterxml.jackson.core.type.TypeReference) JsonParseException(com.fasterxml.jackson.core.JsonParseException) RestAssured.when(com.jayway.restassured.RestAssured.when) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) DefinitionDTO(org.talend.components.service.rest.dto.DefinitionDTO) BDDMockito(org.mockito.BDDMockito) List(java.util.List) DatastoreDefinition(org.talend.components.common.datastore.DatastoreDefinition) MockDatastoreDefinition(org.talend.components.service.rest.mock.MockDatastoreDefinition) CONFIGURATION(org.talend.components.service.rest.dto.ConnectorTypology.CONFIGURATION) COMPONENT(org.talend.components.service.rest.DefinitionType.COMPONENT) ServiceConstants(org.talend.components.service.rest.ServiceConstants) AbstractSpringIntegrationTests(org.talend.components.service.rest.AbstractSpringIntegrationTests) INCOMING(org.talend.components.api.component.ConnectorTopology.INCOMING) SINK(org.talend.components.service.rest.dto.ConnectorTypology.SINK) ConnectorTypology(org.talend.components.service.rest.dto.ConnectorTypology) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) OK(org.springframework.http.HttpStatus.OK) DefinitionType(org.talend.components.service.rest.DefinitionType) Assert.assertEquals(org.junit.Assert.assertEquals) DefinitionDTO(org.talend.components.service.rest.dto.DefinitionDTO) Arrays.asList(java.util.Arrays.asList) List(java.util.List) MockComponentDefinition(org.talend.components.service.rest.mock.MockComponentDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Aggregations

JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 RestAssured.when (com.jayway.restassured.RestAssured.when)1 Response (com.jayway.restassured.response.Response)1 IOException (java.io.IOException)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Matchers.hasSize (org.hamcrest.Matchers.hasSize)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1 BDDMockito (org.mockito.BDDMockito)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 OK (org.springframework.http.HttpStatus.OK)1 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)1