@Test public void testDelete() throws Exception { // the plugin swaps the filter with id > 102 String xml = DELETE_ROAD_102; Document dom = postAsDOM("wfs", xml); // print(dom); assertXpathEvaluatesTo("0", "//wfs:totalInserted", dom); assertXpathEvaluatesTo("0", "//wfs:totalUpdated", dom); assertXpathEvaluatesTo("4", "//wfs:totalDeleted", dom); // check the plugin reports assertTrue(plugin.beforeCommitCalled); assertTrue(plugin.committed); assertTrue(plugin.dataStoreChanged); assertEquals(0, plugin.result.getTotalInserted().intValue()); assertEquals(0, plugin.result.getTotalUpdated().intValue()); assertEquals(4, plugin.result.getTotalDeleted().intValue()); // check the one surviving road segment has id 102 Document roadSegments = getAsDOM( "wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=cite:RoadSegments"); // print(roadSegments); assertXpathEvaluatesTo("1", "count(//cite:RoadSegments)", roadSegments); assertXpathEvaluatesTo("102", "//cite:RoadSegments/cite:FID", roadSegments); }
String handle = delete.getHandle(); long deleted = response.getTotalDeleted().longValue();
@Test public void testDelete() throws Exception { // the plugin swaps the filter with id > 102 String xml = DELETE_ROAD_102; Document dom = postAsDOM("wfs", xml); // print(dom); assertXpathEvaluatesTo("0", "//wfs:totalInserted", dom); assertXpathEvaluatesTo("0", "//wfs:totalUpdated", dom); assertXpathEvaluatesTo("4", "//wfs:totalDeleted", dom); // check the plugin reports assertTrue(plugin.beforeCommitCalled); assertTrue(plugin.committed); assertTrue(plugin.dataStoreChanged); assertEquals(0, plugin.result.getTotalInserted().intValue()); assertEquals(0, plugin.result.getTotalUpdated().intValue()); assertEquals(4, plugin.result.getTotalDeleted().intValue()); // check the one surviving road segment has id 102 Document roadSegments = getAsDOM( "wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=cite:RoadSegments"); // print(roadSegments); assertXpathEvaluatesTo("1", "count(//cite:RoadSegments)", roadSegments); assertXpathEvaluatesTo("102", "//cite:RoadSegments/cite:FID", roadSegments); }
@Test public void testReplaceWithDelete() throws Exception { // the plugin will remove all elements and replace it with a fixed delete on road 106 plugin.beforeTransaction = TransactionCallbackTester::replaceWithFixedRoadsDelete; String xml = DELETE_ROAD_102; Document dom = postAsDOM("wfs", xml); // print(dom); assertXpathEvaluatesTo("0", "//wfs:totalInserted", dom); assertXpathEvaluatesTo("0", "//wfs:totalUpdated", dom); assertXpathEvaluatesTo("1", "//wfs:totalDeleted", dom); // check the plugin reports assertTrue(plugin.beforeCommitCalled); assertTrue(plugin.committed); assertTrue(plugin.dataStoreChanged); assertEquals(0, plugin.result.getTotalInserted().intValue()); assertEquals(0, plugin.result.getTotalUpdated().intValue()); assertEquals(1, plugin.result.getTotalDeleted().intValue()); // check the new feature is there Document roadSegments = getAsDOM( "wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=cite:RoadSegments"); // print(roadSegments); assertXpathEvaluatesTo("4", "count(//cite:RoadSegments)", roadSegments); assertXpathEvaluatesTo("0", "count(//cite:RoadSegments[cite:FID = 106])", roadSegments); } }
@Test public void testReplaceWithInsert() throws Exception { // the plugin will remove all elements and replace it with an insert plugin.beforeTransaction = TransactionCallbackTester::replaceWithFixedRoadsInsert; String xml = DELETE_ROAD_102; Document dom = postAsDOM("wfs", xml); // print(dom); assertXpathEvaluatesTo("1", "//wfs:totalInserted", dom); assertXpathEvaluatesTo("0", "//wfs:totalUpdated", dom); assertXpathEvaluatesTo("0", "//wfs:totalDeleted", dom); // check the plugin reports assertTrue(plugin.beforeCommitCalled); assertTrue(plugin.committed); assertTrue(plugin.dataStoreChanged); assertEquals(1, plugin.result.getTotalInserted().intValue()); assertEquals(0, plugin.result.getTotalUpdated().intValue()); assertEquals(0, plugin.result.getTotalDeleted().intValue()); // check the new feature is there Document roadSegments = getAsDOM( "wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=cite:RoadSegments"); // print(roadSegments); assertXpathEvaluatesTo("6", "count(//cite:RoadSegments)", roadSegments); assertXpathEvaluatesTo( "New Road", "//cite:RoadSegments[cite:FID = 107]/cite:NAME", roadSegments); }
@Test public void testReplaceWithUpdate() throws Exception { // the plugin will remove all elements and replace it with a fixed update on Dirt road plugin.beforeTransaction = TransactionCallbackTester::replaceWithFixedRoadsUpdate; String xml = DELETE_ROAD_102; Document dom = postAsDOM("wfs", xml); // print(dom); assertXpathEvaluatesTo("0", "//wfs:totalInserted", dom); assertXpathEvaluatesTo("1", "//wfs:totalUpdated", dom); assertXpathEvaluatesTo("0", "//wfs:totalDeleted", dom); // check the plugin reports assertTrue(plugin.beforeCommitCalled); assertTrue(plugin.committed); assertTrue(plugin.dataStoreChanged); assertEquals(0, plugin.result.getTotalInserted().intValue()); assertEquals(1, plugin.result.getTotalUpdated().intValue()); assertEquals(0, plugin.result.getTotalDeleted().intValue()); // check the new feature is there Document roadSegments = getAsDOM( "wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=cite:RoadSegments"); // print(roadSegments); assertXpathEvaluatesTo("5", "count(//cite:RoadSegments)", roadSegments); assertXpathEvaluatesTo( "Clean Road", "//cite:RoadSegments[cite:FID = 106]/cite:NAME", roadSegments); }
@Test public void testReplaceWithInsert() throws Exception { // the plugin will remove all elements and replace it with an insert plugin.beforeTransaction = TransactionCallbackTester::replaceWithFixedRoadsInsert; String xml = DELETE_ROAD_102; Document dom = postAsDOM("wfs", xml); // print(dom); assertXpathEvaluatesTo("1", "//wfs:totalInserted", dom); assertXpathEvaluatesTo("0", "//wfs:totalUpdated", dom); assertXpathEvaluatesTo("0", "//wfs:totalDeleted", dom); // check the plugin reports assertTrue(plugin.beforeCommitCalled); assertTrue(plugin.committed); assertTrue(plugin.dataStoreChanged); assertEquals(1, plugin.result.getTotalInserted().intValue()); assertEquals(0, plugin.result.getTotalUpdated().intValue()); assertEquals(0, plugin.result.getTotalDeleted().intValue()); // check the new feature is there Document roadSegments = getAsDOM( "wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=cite:RoadSegments"); // print(roadSegments); assertXpathEvaluatesTo("6", "count(//cite:RoadSegments)", roadSegments); assertXpathEvaluatesTo( "New Road", "//cite:RoadSegments[cite:FID = 107]/cite:NAME", roadSegments); }
@Test public void testReplaceWithUpdate() throws Exception { // the plugin will remove all elements and replace it with a fixed delete on road 106 plugin.beforeTransaction = TransactionCallbackTester::replaceWithFixedRoadsUpdate; String xml = DELETE_ROAD_102; Document dom = postAsDOM("wfs", xml); // print(dom); assertXpathEvaluatesTo("0", "//wfs:totalInserted", dom); assertXpathEvaluatesTo("1", "//wfs:totalUpdated", dom); assertXpathEvaluatesTo("0", "//wfs:totalDeleted", dom); // check the plugin reports assertTrue(plugin.beforeCommitCalled); assertTrue(plugin.committed); assertTrue(plugin.dataStoreChanged); assertEquals(0, plugin.result.getTotalInserted().intValue()); assertEquals(1, plugin.result.getTotalUpdated().intValue()); assertEquals(0, plugin.result.getTotalDeleted().intValue()); // check the new feature is there Document roadSegments = getAsDOM( "wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=cite:RoadSegments"); // print(roadSegments); assertXpathEvaluatesTo("5", "count(//cite:RoadSegments)", roadSegments); assertXpathEvaluatesTo( "Clean Road", "//cite:RoadSegments[cite:FID = 106]/cite:NAME", roadSegments); }
@Test public void testReplaceWithDelete() throws Exception { // the plugin will remove all elements and replace it with a fixed delete on road 106 plugin.beforeTransaction = TransactionCallbackTester::replaceWithFixedRoadsDelete; String xml = DELETE_ROAD_102; Document dom = postAsDOM("wfs", xml); // print(dom); assertXpathEvaluatesTo("0", "//wfs:totalInserted", dom); assertXpathEvaluatesTo("0", "//wfs:totalUpdated", dom); assertXpathEvaluatesTo("1", "//wfs:totalDeleted", dom); // check the plugin reports assertTrue(plugin.beforeCommitCalled); assertTrue(plugin.committed); assertTrue(plugin.dataStoreChanged); assertEquals(0, plugin.result.getTotalInserted().intValue()); assertEquals(0, plugin.result.getTotalUpdated().intValue()); assertEquals(1, plugin.result.getTotalDeleted().intValue()); // check the new feature is there Document roadSegments = getAsDOM( "wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=cite:RoadSegments"); // print(roadSegments); assertXpathEvaluatesTo("4", "count(//cite:RoadSegments)", roadSegments); assertXpathEvaluatesTo("0", "count(//cite:RoadSegments[cite:FID = 106])", roadSegments); } }
assertEquals(1, plugin.result.getTotalInserted().intValue()); assertEquals(0, plugin.result.getTotalUpdated().intValue()); assertEquals(0, plugin.result.getTotalDeleted().intValue());
assertEquals(1, plugin.result.getTotalInserted().intValue()); assertEquals(0, plugin.result.getTotalUpdated().intValue()); assertEquals(0, plugin.result.getTotalDeleted().intValue());
assertEquals(0, plugin.result.getTotalInserted().intValue()); assertEquals(1, plugin.result.getTotalUpdated().intValue()); assertEquals(0, plugin.result.getTotalDeleted().intValue());
assertEquals(0, plugin.result.getTotalInserted().intValue()); assertEquals(1, plugin.result.getTotalUpdated().intValue()); assertEquals(0, plugin.result.getTotalDeleted().intValue());