use of com.baremaps.model.StyleSet in project baremaps by baremaps.
the class StylesResource method getStyleSet.
@Override
public Response getStyleSet() {
List<UUID> ids = jdbi.withHandle(handle -> handle.createQuery("select id from styles").mapTo(UUID.class).list());
StyleSet styleSet = new StyleSet();
List<StyleSetEntry> entries = new ArrayList<>();
String address = uriInfo.getRequestUri().toString();
for (UUID id : ids) {
Link link = new Link();
link.setHref(address + id);
link.setType("application/vnd.mapbox.style+json");
link.setRel("stylesheet");
StyleSetEntry entry = new StyleSetEntry();
entry.setId(id);
entry.setLinks(List.of(link));
entries.add(entry);
}
styleSet.setStyles(entries);
return Response.ok(styleSet).build();
}
use of com.baremaps.model.StyleSet in project baremaps by baremaps.
the class StylesResourceIntegrationTest method test.
@Test
public void test() {
// List the styles
StyleSet styles = target().path("/styles").request().get(StyleSet.class);
assertEquals(0, styles.getStyles().size());
// Create a new style with the service
MbStyle style = new MbStyle();
style.setName("test");
target().path("/styles").request(MediaType.APPLICATION_JSON).post(Entity.entity(style, MediaType.valueOf("application/vnd.mapbox.style+json")));
// List the styles
styles = target().path("/styles").request().get(StyleSet.class);
assertEquals(1, styles.getStyles().size());
// Get the style
UUID id = styles.getStyles().get(0).getId();
style = target().path("/styles/" + id).request().get(MbStyle.class);
assertEquals("test", style.getName());
// Delete the style
target().path("/styles/" + styles.getStyles().get(0).getId()).request().delete();
// List the styles
styles = target().path("/styles").request().get(StyleSet.class);
assertEquals(0, styles.getStyles().size());
}
Aggregations