use of io.jawg.osmcontributor.ui.managers.PoiManager in project osm-contributor by jawg.
the class PoiManagerTest method testSaveAndQuery.
@Test
public void testSaveAndQuery() {
PoiManager poiManager = component.getPoiManager();
Poi poi = getPoi(poiManager.savePoiType(getPoiType()), 1);
Poi saved = poiManager.savePoi(poi);
Poi queried = poiManager.queryForId(saved.getId());
assertThat(queried.getName()).isEqualTo("MyPoi1");
assertThat(queried.getLatitude()).isEqualTo(42.0);
assertThat(queried.getLongitude()).isEqualTo(73.0);
assertThat(queried.getUpdated()).isFalse();
}
use of io.jawg.osmcontributor.ui.managers.PoiManager in project osm-contributor by jawg.
the class PoiManagerTest method testBulkSaveAndBulkUpdate.
@Test
public void testBulkSaveAndBulkUpdate() {
PoiManager poiManager = component.getPoiManager();
PoiType poiType = poiManager.savePoiType(getPoiType());
// try to save and then update 1000 pois.
// 1000 because it can happen in real life and pose problems if we try to do an "IN" sql clause
List<Poi> pois = new ArrayList<>(1000);
for (int i = 0; i < 1000; i++) {
pois.add(getPoi(poiType, i));
}
poiManager.savePois(pois);
for (Poi poi : pois) {
assertThat(poi.getId()).isNotNull();
}
for (Poi poi : pois) {
Map<String, String> tags = new HashMap<>();
tags.put("tag2", "value2");
poi.getTags().clear();
poi.applyChanges(tags);
}
List<Poi> savedPois = poiManager.savePois(pois);
for (Poi poi : savedPois) {
assertThat(poi.getTags()).hasSize(1);
PoiTag tag = poi.getTags().iterator().next();
assertThat(tag.getKey()).isEqualTo("tag2");
assertThat(tag.getValue()).isEqualTo("value2");
}
}
Aggregations