use of org.talend.components.service.rest.dto.DefinitionDTO in project components by Talend.
the class DefinitionsControllerTest method shouldListDefinitions.
public //
void shouldListDefinitions(//
List<String> names, //
Class clazz, //
Function<List<String>, Map<String, ? extends Definition>> provider, //
DefinitionType wantedType, String expectedType) throws IOException {
// given
//
BDDMockito.given(delegate.getDefinitionsMapByType(clazz)).willReturn(provider.apply(names));
// when
final Response response = when().get(getVersionPrefix() + "/definitions/" + wantedType).andReturn();
// then
assertEquals(OK.value(), response.getStatusCode());
List<DefinitionDTO> actual = objectMapper.readValue(response.asInputStream(), new TypeReference<List<DefinitionDTO>>() {
});
assertEquals(names.size(), actual.size());
actual.forEach(d -> {
assertEquals(expectedType, d.getType());
// it's expected
assertTrue(names.contains(d.getName().substring("mock ".length())));
});
}
use of org.talend.components.service.rest.dto.DefinitionDTO in project components by Talend.
the class DefinitionsControllerTest method shouldFilterComponentsByTypology.
public void shouldFilterComponentsByTypology(ConnectorTypology wantedTypology, 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.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, // it's
actual.stream().filter(dto -> dto.getTypologies().contains(wantedTypology.name())).count());
}
use of org.talend.components.service.rest.dto.DefinitionDTO in project components by Talend.
the class JdbcComponentTestIT method getJdbcDefinition.
@Test
public void getJdbcDefinition() throws java.io.IOException {
// when
Response response = //
given().accept(APPLICATION_JSON_UTF8_VALUE).expect().statusCode(200).log().ifError().get(getVersionPrefix() + "/definitions/DATA_STORE");
// then
List<DefinitionDTO> definitions = mapper.readerFor(TypeFactory.defaultInstance().constructCollectionType(List.class, DefinitionDTO.class)).readValue(response.asInputStream());
DefinitionDTO jdbcDef = null;
for (DefinitionDTO definition : definitions) {
if (DATA_STORE_DEFINITION_NAME.equals(definition.getName())) {
jdbcDef = definition;
break;
}
}
assertNotNull(jdbcDef);
}
Aggregations