use of io.gravitee.management.model.FetcherEntity in project gravitee-management-rest-api by gravitee-io.
the class FetchersResourceTest method shouldGetFetcherWithoutSchema.
@Test
public void shouldGetFetcherWithoutSchema() {
Mockito.reset(fetcherService);
FetcherEntity fetcherEntity = new FetcherEntity();
fetcherEntity.setId("my-id");
when(fetcherService.findAll()).thenReturn(Collections.singleton(fetcherEntity));
when(fetcherService.getSchema(anyString())).thenReturn("schema");
final Response response = target().request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatusCode.OK_200);
Set set = response.readEntity(Set.class);
assertThat(set).isNotEmpty();
assertThat(set).hasSize(1);
Object o = set.iterator().next();
assertThat(o).isNotNull();
assertThat(o).isInstanceOf(LinkedHashMap.class);
LinkedHashMap<String, String> elt = (LinkedHashMap<String, String>) o;
assertThat(elt).hasSize(1);
assertThat(elt.get("id")).isEqualTo("my-id");
verify(fetcherService, times(1)).findAll();
verify(fetcherService, times(0)).getSchema(anyString());
}
use of io.gravitee.management.model.FetcherEntity in project gravitee-management-rest-api by gravitee-io.
the class FetcherServiceImpl method findAll.
@Override
public Set<FetcherEntity> findAll() {
try {
LOGGER.debug("List all fetchers");
final Collection<FetcherPlugin> fetcherDefinitions = fetcherPluginManager.findAll();
return fetcherDefinitions.stream().map(fetcherDefinition -> convert(fetcherDefinition, false)).collect(Collectors.toSet());
} catch (Exception ex) {
LOGGER.error("An error occurs while trying to list all fetchers", ex);
throw new TechnicalManagementException("An error occurs while trying to list all fetchers", ex);
}
}
Aggregations