コード例 #1
0
  @Test
  public void testKBaseAdded() {
    KProject kproj = new KProjectImpl();

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

    KBase kbase1 = kproj.newKBase("org.test1", "KBase1");
    assertTrue(dirtyLog.getAddedKBases().contains(kbase1.getQName()));
  }
コード例 #2
0
  @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()));
  }
コード例 #3
0
  @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()));
  }
コード例 #4
0
  @Test
  public void testKProjectModified() {
    KProject kproj = new KProjectImpl();

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

    assertFalse(dirtyLog.isKProjectDirty());

    kproj.setKProjectPath("src/main/resources/");
    kproj.setKBasesPath("src/kbases");

    assertTrue(dirtyLog.isKProjectDirty());
  }
コード例 #5
0
  @Test
  public void testKSessionDoesntExistsModify() {
    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");
    kSession.setNamespace("org.test2");

    assertTrue(dirtyLog.getRemovedKSessions().contains("org.test1.KSession1"));
    assertTrue(dirtyLog.getAddedKSessions().contains("org.test2.KSession1"));
  }
コード例 #6
0
  @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"));
  }
コード例 #7
0
  @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"));
  }
コード例 #8
0
  @Test
  public void testKSessionExistsRemovedAdded() {
    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");

    dirtyLog.reset();

    kbase1.removeKSession(kSession.getQName());
    assertTrue(dirtyLog.getRemovedKSessions().contains("org.domain.KSession1"));

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

    assertEquals(0, dirtyLog.getRemovedKSessions().size());
    assertTrue(dirtyLog.getAddedKSessions().contains("org.domain.KSession1"));
  }
コード例 #9
0
  @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"));
  }
コード例 #10
0
  @Test
  public void testKsessionExistsModifyRemovedAddedWithOverlappingNames() {
    KProject kproj = new KProjectImpl();

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

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

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

    KSession kSession2 = kbase1.newKSession("org.test1", "KSession2");

    dirtyLog.reset();

    kSession1.setNamespace("org.test2");

    kSession2.setName("KSession1");

    assertEquals(1, dirtyLog.getRemovedKSessions().size());
    assertEquals(2, dirtyLog.getAddedKSessions().size());

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

    kbase1.removeKSession(kSession1.getQName());
    assertEquals(2, dirtyLog.getRemovedKSessions().size());
    assertEquals(1, dirtyLog.getAddedKSessions().size());

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

    kbase1.removeKSession(kSession2.getQName());
    assertEquals(3, dirtyLog.getRemovedKSessions().size());
    assertEquals(0, dirtyLog.getAddedKSessions().size());

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

    kbase1.newKSession(kSession1.getNamespace(), kSession1.getName());
    assertEquals(2, dirtyLog.getRemovedKSessions().size());
    assertEquals(1, dirtyLog.getAddedKSessions().size());

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

    kbase1.newKSession(kSession2.getNamespace(), kSession2.getName());
    assertEquals(1, dirtyLog.getRemovedKSessions().size());
    assertEquals(2, dirtyLog.getAddedKSessions().size());

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