use of com.github.sebastianfrey.joa.models.Service in project joa by sebastianfrey.
the class GeoPackageService method getServices.
@Override
public Services getServices() {
Services services = new Services();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(workspace.toPath(), "*.gpkg")) {
for (Path path : stream) {
if (!Files.isDirectory(path)) {
String fileName = path.getFileName().toString();
String serviceId = fileName.replaceAll(".gpkg", "");
Service service = new Service().serviceId(serviceId).title(serviceId);
services.addService(service);
}
}
} catch (IOException ex) {
throw new NotFoundException("Failed to fetch services.", ex);
}
return services;
}
use of com.github.sebastianfrey.joa.models.Service in project joa by sebastianfrey.
the class OGCAPIServiceResourceTest method setup.
@BeforeEach
void setup() {
queryables = new Queryables();
service = new Service().serviceId("service1").title("service1 title").description("service1 description");
services = new Services().service(service);
bbox = new Bbox().minX(-104.807496).minY(39.71408499999999).maxX(-104.79948).maxY(39.72001399999999);
spatial = new Spatial().bbox(bbox).crs(CrsUtils.crs84());
collection = new Collection().serviceId("service1").collectionId("collection1").crs(CrsUtils.crs84()).spatial(spatial).title("collection1 title").description("collection1 description");
collections = new Collections().serviceId("serviceId").title("collections title").collection(collection);
items = new TestItems().serviceId("service1").collectionId("collection1").numberMatched(Long.valueOf(0));
item = new TestItem().serviceId("service1").collectionId("collection1");
conformance = new Conformance().serviceId("service1").conformsTo(Conformance.FEATURES_CORE).conformsTo(Conformance.FEATURES_GEOJSON).conformsTo(Conformance.FEATURES_OAS30);
}
use of com.github.sebastianfrey.joa.models.Service in project joa by sebastianfrey.
the class OGCAPIServiceResourceTest method should_return_the_requested_service.
@Test
public void should_return_the_requested_service() {
when(DAO.getService("service1")).thenReturn(service);
Service found = EXT.target("/service1").queryParam("f", "json").request().get(Service.class);
// verify that ogcApisService.getService(...) was called
verify(DAO).getService("service1");
assertThat(found).isNotNull();
assertThat(found.getTitle()).isEqualTo(service.getTitle());
assertThat(found.getDescription()).isEqualTo(service.getDescription());
assertThat(found.getLinks()).satisfies((links) -> {
assertThat(links).isNotEmpty();
assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.SELF));
assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.SERVICE_DESC) && link.getType().equals(MediaType.APPLICATION_OPENAPI_JSON));
assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.SERVICE_DESC) && link.getType().equals(MediaType.APPLICATION_OPENAPI_YAML));
assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.CONFORMANCE));
assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.DATA));
});
}
use of com.github.sebastianfrey.joa.models.Service in project joa by sebastianfrey.
the class GeoPackageServiceTest method should_return_service.
@Test
public void should_return_service() {
Service service = geoPackageService.getService(TEST_SERVICE);
assertThat(service).isNotNull();
assertThat(service.getServiceId()).isEqualTo("example");
assertThat(service.getTitle()).isEqualTo("example");
}
Aggregations