use of io.gravitee.management.model.FetcherEntity in project gravitee-management-rest-api by gravitee-io.
the class FetchersResourceTest method shouldGetFetcherWithUnknownExpand.
@Test
public void shouldGetFetcherWithUnknownExpand() {
Mockito.reset(fetcherService);
FetcherEntity fetcherEntity = new FetcherEntity();
fetcherEntity.setId("my-id");
when(fetcherService.findAll()).thenReturn(Collections.singleton(fetcherEntity));
when(fetcherService.getSchema(anyString())).thenReturn("my-schema");
final Response response = target().queryParam("expand", "unknown").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 FetchersResourceTest method shouldGetFetcherWithExpandSchema.
@Test
public void shouldGetFetcherWithExpandSchema() {
Mockito.reset(fetcherService);
FetcherEntity fetcherEntity = new FetcherEntity();
fetcherEntity.setId("my-id");
when(fetcherService.findAll()).thenReturn(Collections.singleton(fetcherEntity));
when(fetcherService.getSchema(anyString())).thenReturn("my-schema");
final Response response = target().queryParam("expand", "schema").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(2);
assertThat(elt.get("id")).isEqualTo("my-id");
assertThat(elt.get("schema")).isEqualTo("my-schema");
verify(fetcherService, times(1)).findAll();
verify(fetcherService, times(1)).getSchema(anyString());
}
use of io.gravitee.management.model.FetcherEntity in project gravitee-management-rest-api by gravitee-io.
the class FetcherServiceImpl method convert.
private FetcherEntity convert(FetcherPlugin fetcherPlugin, boolean withPlugin) {
FetcherEntity entity = new FetcherEntity();
entity.setId(fetcherPlugin.id());
entity.setDescription(fetcherPlugin.manifest().description());
entity.setName(fetcherPlugin.manifest().name());
entity.setVersion(fetcherPlugin.manifest().version());
if (withPlugin) {
// Plugin information
Plugin plugin = fetcherPlugin;
PluginEntity pluginEntity = new PluginEntity();
pluginEntity.setPlugin(plugin.clazz());
pluginEntity.setPath(plugin.path().toString());
pluginEntity.setType(plugin.type().toString().toLowerCase());
pluginEntity.setDependencies(plugin.dependencies());
entity.setPlugin(pluginEntity);
}
return entity;
}
use of io.gravitee.management.model.FetcherEntity in project gravitee-management-rest-api by gravitee-io.
the class FetcherResourceTest method shouldGetFetcherSchema.
@Test
public void shouldGetFetcherSchema() {
Mockito.reset(fetcherService);
FetcherEntity fetcherEntity = new FetcherEntity();
fetcherEntity.setId("my-id");
when(fetcherService.findById("my-id")).thenReturn(fetcherEntity);
when(fetcherService.getSchema(anyString())).thenReturn("my-schema");
final Response response = target().path("schema").request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatusCode.OK_200);
String o = response.readEntity(String.class);
assertThat(o).isNotNull();
assertThat(o).isEqualTo("my-schema");
verify(fetcherService, times(1)).findById("my-id");
verify(fetcherService, times(1)).getSchema(anyString());
}
use of io.gravitee.management.model.FetcherEntity in project gravitee-management-rest-api by gravitee-io.
the class FetcherResourceTest method shouldGetFetcherWithoutSchema.
@Test
public void shouldGetFetcherWithoutSchema() {
Mockito.reset(fetcherService);
FetcherEntity fetcherEntity = new FetcherEntity();
fetcherEntity.setId("my-id");
when(fetcherService.findById("my-id")).thenReturn(fetcherEntity);
when(fetcherService.getSchema(anyString())).thenReturn("schema");
final Response response = target().request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatusCode.OK_200);
Object o = response.readEntity(Object.class);
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)).findById("my-id");
verify(fetcherService, times(0)).getSchema(anyString());
}
Aggregations