@Test
  public void testKSessionExistsModifyRemovedAdded() {
    KProject kproj = new KProjectImpl();

    KProjectChangeLog dirtyLog = new KProjectChangeLog();
    kproj.setListener(dirtyLog);

    KBase kbase1 = kproj.newKBase("org.test1", "KBase1");

    KSession kSession = kbase1.newKSession("org.test1", "KSession1");

    dirtyLog.reset();

    kSession.setNamespace("org.test2");

    assertTrue(dirtyLog.getRemovedKSessions().contains("org.test1.KSession1"));
    assertTrue(dirtyLog.getAddedKSessions().contains("org.test2.KSession1"));

    kbase1.removeKSession(kSession.getQName());
    assertEquals(2, dirtyLog.getRemovedKSessions().size());
    assertEquals(0, dirtyLog.getAddedKSessions().size());
    assertTrue(dirtyLog.getRemovedKSessions().contains("org.test2.KSession1"));

    kbase1.newKSession(kSession.getNamespace(), kSession.getName());

    assertEquals(1, dirtyLog.getRemovedKSessions().size());
    assertEquals(1, dirtyLog.getAddedKSessions().size());
    assertTrue(dirtyLog.getRemovedKSessions().contains("org.test1.KSession1"));
    assertTrue(dirtyLog.getAddedKSessions().contains("org.test2.KSession1"));
  }
  @Test
  public void testKSessionModified() {
    KProject kproj = new KProjectImpl();

    KProjectChangeLog dirtyLog = new KProjectChangeLog();
    kproj.setListener(dirtyLog);

    assertFalse(dirtyLog.isKProjectDirty());

    KBase kbase1 = kproj.newKBase("org.test1", "KBase1");

    KSession kSession = kbase1.newKSession("org.test1", "KSession1");
    kSession.setClockType(ClockTypeOption.get("pseudo"));
    kSession.setType("stateless");

    kSession.setClockType(ClockTypeOption.get("realtime"));
    assertTrue(dirtyLog.getAddedKSessions().contains("org.test1.KSession1"));

    dirtyLog.reset();

    kSession.setType("stateful");
    assertTrue(dirtyLog.getAddedKSessions().contains("org.test1.KSession1"));

    kbase1.removeKSession(kSession.getQName());
    assertFalse(dirtyLog.getAddedKSessions().contains("org.test1.KSession1"));
    assertTrue(dirtyLog.getRemovedKSessions().contains("org.test1.KSession1"));
  }
  @Test
  public void testKSessioExistsnQNameModified() {
    KProject kproj = new KProjectImpl();

    KProjectChangeLog dirtyLog = new KProjectChangeLog();
    kproj.setListener(dirtyLog);

    assertFalse(dirtyLog.isKProjectDirty());

    KBase kbase1 = kproj.newKBase("org.test1", "KBase1");

    KSession kSession = kbase1.newKSession("org.test1", "KSession1");

    dirtyLog.reset();

    kSession.setNamespace("org.test2");

    assertTrue(dirtyLog.getAddedKSessions().contains("org.test2.KSession1"));
    assertTrue(dirtyLog.getRemovedKSessions().contains("org.test1.KSession1"));

    kSession.setName("KSession2");

    assertTrue(dirtyLog.getRemovedKSessions().contains("org.test2.KSession1"));
    assertTrue(dirtyLog.getRemovedKSessions().contains("org.test1.KSession1"));
    assertTrue(dirtyLog.getAddedKSessions().contains("org.test2.KSession2"));
  }
  @Test
  public void testKSessionAdded() {
    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(kSession.getQName()));
  }
  @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"));
  }