@Test public void testKBaseModified() { KProject kproj = new KProjectImpl(); KProjectChangeLog dirtyLog = new KProjectChangeLog(); kproj.setListener(dirtyLog); KBase kbase1 = kproj.newKBase("org.test1", "KBase1"); kbase1.setEqualsBehavior(AssertBehaviorOption.IDENTITY); kbase1.setEventProcessingMode(EventProcessingOption.CLOUD); kbase1.setEqualsBehavior(AssertBehaviorOption.EQUALITY); assertTrue(dirtyLog.getAddedKBases().contains(kbase1.getQName())); dirtyLog.reset(); kbase1.setEventProcessingMode(EventProcessingOption.STREAM); assertTrue(dirtyLog.getAddedKBases().contains(kbase1.getQName())); dirtyLog.reset(); kbase1.setFiles(new ArrayList<String>()); assertTrue(dirtyLog.getAddedKBases().contains(kbase1.getQName())); kproj.removeKBase(kbase1.getQName()); assertEquals(1, dirtyLog.getRemovedKBases().size()); assertEquals(0, dirtyLog.getAddedKBases().size()); assertTrue(dirtyLog.getRemovedKBases().contains(kbase1.getQName())); }
@Test public void testKBaseRemoved() { KProject kproj = new KProjectImpl(); KProjectChangeLog dirtyLog = new KProjectChangeLog(); kproj.setListener(dirtyLog); KBase kbase1 = kproj.newKBase("org.test1", "KBase1"); assertTrue(dirtyLog.getAddedKBases().contains(kbase1.getQName())); kproj.removeKBase(kbase1.getQName()); assertTrue(dirtyLog.getRemovedKBases().contains(kbase1.getQName())); assertFalse(dirtyLog.getAddedKBases().contains(kbase1.getQName())); }
@Test public void testKBaseDoesntExistsModify() { KProject kproj = new KProjectImpl(); KProjectChangeLog dirtyLog = new KProjectChangeLog(); kproj.setListener(dirtyLog); KBase kbase1 = kproj.newKBase("org.test1", "KBase1"); kproj.removeKBase(kbase1.getQName()); kbase1 = kproj.newKBase("org.test2", "KBase1"); assertEquals(1, dirtyLog.getRemovedKBases().size()); assertEquals(1, dirtyLog.getAddedKBases().size()); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase1")); assertTrue(dirtyLog.getAddedKBases().contains("org.test2.KBase1")); }
@Test public void testKBaseExistsQNameModified() { KProjectImpl kproj = (KProjectImpl) new KProjectImpl(); KProjectChangeLog dirtyLog = new KProjectChangeLog(); kproj.setListener(dirtyLog); KBase kbase1 = kproj.newKBase("org.test1", "KBase1"); dirtyLog.reset(); kbase1.setNamespace("org.test2"); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase1")); assertTrue(dirtyLog.getAddedKBases().contains("org.test2.KBase1")); kbase1.setName("KBase2"); assertEquals(2, dirtyLog.getRemovedKBases().size()); assertEquals(1, dirtyLog.getAddedKBases().size()); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase1")); assertTrue(dirtyLog.getRemovedKBases().contains("org.test2.KBase1")); assertTrue(dirtyLog.getAddedKBases().contains("org.test2.KBase2")); }
@Test public void testKBaseExistsModifyRemovedAddedWithOverlappingNames() { KProject kproj = new KProjectImpl(); KProjectChangeLog dirtyLog = new KProjectChangeLog(); kproj.setListener(dirtyLog); KBase kbase1 = kproj.newKBase("org.test1", "KBase1"); KBase kbase2 = kproj.newKBase("org.test1", "KBase2"); dirtyLog.reset(); kbase1.setNamespace("org.test2"); kbase2.setName("KBase1"); assertEquals(1, dirtyLog.getRemovedKBases().size()); assertEquals(2, dirtyLog.getAddedKBases().size()); assertTrue(dirtyLog.getAddedKBases().contains("org.test2.KBase1")); assertTrue(dirtyLog.getAddedKBases().contains("org.test1.KBase1")); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase2")); kproj.removeKBase(kbase1.getQName()); assertEquals(2, dirtyLog.getRemovedKBases().size()); assertEquals(1, dirtyLog.getAddedKBases().size()); assertTrue(dirtyLog.getRemovedKBases().contains("org.test2.KBase1")); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase2")); assertTrue(dirtyLog.getAddedKBases().contains("org.test1.KBase1")); kproj.removeKBase(kbase2.getQName()); assertEquals(3, dirtyLog.getRemovedKBases().size()); assertEquals(0, dirtyLog.getAddedKBases().size()); assertTrue(dirtyLog.getRemovedKBases().contains("org.test2.KBase1")); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase1")); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase2")); kproj.newKBase(kbase1.getNamespace(), kbase1.getName()); assertEquals(2, dirtyLog.getRemovedKBases().size()); assertEquals(1, dirtyLog.getAddedKBases().size()); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase1")); assertTrue(dirtyLog.getRemovedKBases().contains("org.test1.KBase2")); assertTrue(dirtyLog.getAddedKBases().contains("org.test2.KBase1")); }
@Test public void testKSessionRemoved() { KProject kproj = new KProjectImpl(); KProjectChangeLog dirtyLog = new KProjectChangeLog(); kproj.setListener(dirtyLog); KBase kbase1 = kproj.newKBase("org.test1", "KBase1"); KSession kSession = kbase1.newKSession("org.domain", "KSession1"); assertTrue(dirtyLog.getAddedKSessions().contains("org.domain.KSession1")); kbase1.removeKSession(kSession.getQName()); assertEquals(0, dirtyLog.getRemovedKBases().size()); assertEquals(1, dirtyLog.getAddedKBases().size()); assertTrue(dirtyLog.getRemovedKSessions().contains("org.domain.KSession1")); assertFalse(dirtyLog.getAddedKSessions().contains("org.domain.KSession1")); }