@Test public void testShouldUpdate2() throws Exception { Feed oldFeed = parser.parseAndValidate(this.getClass().getResourceAsStream(FEED_XML)); String cluster = "testCluster"; Feed newFeed = (Feed) oldFeed.clone(); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, cluster)); newFeed.setGroups("newgroups"); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, cluster)); newFeed.getLateArrival().setCutOff(Frequency.fromString("hours(8)")); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, cluster)); newFeed.setFrequency(Frequency.fromString("days(1)")); Assert.assertTrue(UpdateHelper.shouldUpdate(oldFeed, newFeed, cluster)); Process oldProcess = processParser.parseAndValidate(this.getClass().getResourceAsStream(PROCESS_XML)); Process newProcess = (Process) oldProcess.clone(); newProcess.getRetry().setPolicy(PolicyType.FINAL); Assert.assertFalse(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster)); newProcess.getLateProcess().getLateInputs().remove(1); Assert.assertFalse(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster)); newProcess.getLateProcess().setPolicy(PolicyType.PERIODIC); Assert.assertFalse(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster)); newProcess.setFrequency(Frequency.fromString("days(1)")); Assert.assertTrue(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster)); }
@Test public void testShouldUpdate() throws Exception { Feed oldFeed = parser.parseAndValidate(this.getClass().getResourceAsStream(FEED_XML)); Feed newFeed = (Feed) oldFeed.clone(); Process process = processParser.parseAndValidate(this.getClass().getResourceAsStream(PROCESS_XML)); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); newFeed.getLateArrival().setCutOff(Frequency.fromString("hours(1)")); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); newFeed.getLateArrival().setCutOff(oldFeed.getLateArrival().getCutOff()); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); FeedHelper.getLocation(newFeed, LocationType.DATA).setPath("/test"); Assert.assertTrue(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); FeedHelper.getLocation(newFeed, LocationType.DATA) .setPath(FeedHelper.getLocation(oldFeed, LocationType.DATA).getPath()); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); newFeed.setFrequency(Frequency.fromString("months(1)")); Assert.assertTrue(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); newFeed.setFrequency(oldFeed.getFrequency()); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); Partition partition = new Partition(); partition.setName("1"); newFeed.getPartitions().getPartitions().add(partition); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); Property property = new Property(); property.setName("1"); property.setValue("1"); newFeed.setProperties(new Properties()); newFeed.getProperties().getProperties().add(property); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); newFeed.getProperties().getProperties().remove(0); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); FeedHelper.getCluster(newFeed, process.getClusters().getClusters().get(0).getName()) .getValidity() .setStart(SchemaHelper.parseDateUTC("2012-11-01T00:00Z")); Assert.assertTrue(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); FeedHelper.getCluster(newFeed, process.getClusters().getClusters().get(0).getName()) .getValidity() .setStart( FeedHelper.getCluster(oldFeed, process.getClusters().getClusters().get(0).getName()) .getValidity() .getStart()); Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process)); }