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());
}
Aggregations