Search in sources :

Example 1 with Services

use of com.github.sebastianfrey.joa.models.Services 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;
}
Also used : Path(java.nio.file.Path) Services(com.github.sebastianfrey.joa.models.Services) OGCAPIService(com.github.sebastianfrey.joa.services.OGCAPIService) Service(com.github.sebastianfrey.joa.models.Service) NotFoundException(javax.ws.rs.NotFoundException) IOException(java.io.IOException)

Example 2 with Services

use of com.github.sebastianfrey.joa.models.Services 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);
}
Also used : Queryables(com.github.sebastianfrey.joa.models.Queryables) Services(com.github.sebastianfrey.joa.models.Services) Spatial(com.github.sebastianfrey.joa.models.Spatial) Bbox(com.github.sebastianfrey.joa.models.Bbox) OGCAPIService(com.github.sebastianfrey.joa.services.OGCAPIService) Service(com.github.sebastianfrey.joa.models.Service) Collection(com.github.sebastianfrey.joa.models.Collection) Conformance(com.github.sebastianfrey.joa.models.Conformance) Collections(com.github.sebastianfrey.joa.models.Collections) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with Services

use of com.github.sebastianfrey.joa.models.Services in project joa by sebastianfrey.

the class OGCAPIServiceResourceTest method should_return_the_services.

@Test
public void should_return_the_services() {
    when(DAO.getServices()).thenReturn(services);
    Services found = EXT.target("/").queryParam("f", "json").request().get(Services.class);
    // verify that ogcApisService.getServices(...) was called
    verify(DAO).getServices();
    assertThat(found.getServices()).satisfies(($services) -> {
        // there must be at least one service
        assertThat($services).isNotEmpty();
        // assert first service
        assertThat($services.get(0)).satisfies(($service) -> {
            // assert service properties
            assertThat($service.getTitle()).isEqualTo(service.getTitle());
            assertThat($service.getDescription()).isEqualTo(service.getDescription());
            // assert service links
            assertThat($service.getLinks()).satisfies((links) -> {
                assertThat(links).isNotEmpty();
                assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.SELF));
                assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.CONFORMANCE));
                assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.SERVICE_DESC));
                assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.DATA));
            });
        });
    });
    // assert global links
    assertThat(found.getLinks()).satisfies((links) -> {
        assertThat(links).isNotEmpty();
        assertThat(links).anyMatch((link) -> link.getRel().equals(Linkable.SELF));
    });
}
Also used : Services(com.github.sebastianfrey.joa.models.Services) Test(org.junit.jupiter.api.Test)

Example 4 with Services

use of com.github.sebastianfrey.joa.models.Services in project joa by sebastianfrey.

the class GeoPackageServiceTest method should_return_services.

@Test
public void should_return_services() {
    Services services = geoPackageService.getServices();
    assertThat(services).isNotNull();
    assertThat(services.getServices()).isNotEmpty();
}
Also used : Services(com.github.sebastianfrey.joa.models.Services) Test(org.junit.jupiter.api.Test)

Aggregations

Services (com.github.sebastianfrey.joa.models.Services)4 Service (com.github.sebastianfrey.joa.models.Service)2 OGCAPIService (com.github.sebastianfrey.joa.services.OGCAPIService)2 Test (org.junit.jupiter.api.Test)2 Bbox (com.github.sebastianfrey.joa.models.Bbox)1 Collection (com.github.sebastianfrey.joa.models.Collection)1 Collections (com.github.sebastianfrey.joa.models.Collections)1 Conformance (com.github.sebastianfrey.joa.models.Conformance)1 Queryables (com.github.sebastianfrey.joa.models.Queryables)1 Spatial (com.github.sebastianfrey.joa.models.Spatial)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 NotFoundException (javax.ws.rs.NotFoundException)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1