Пример #1
0
  @Test
  public void testIfSourceUpdateWorksCorrectly_shouldUpdateEngineeringObject() throws Exception {
    SourceModelA sourceA = new SourceModelA();
    sourceA.setEdbId("sourceA/3");
    sourceA.setName("sourceNameA");
    SourceModelB sourceB = new SourceModelB();
    sourceB.setEdbId("sourceB/3");
    sourceB.setName("sourceNameB");
    EKBCommit commit = getTestEKBCommit().addInsert(sourceA).addInsert(sourceB);
    persist.commit(commit);

    EOModel eo = new EOModel();
    eo.setEdbId("eo/3");
    eo.setRefModelA("sourceA/3");
    eo.setRefModelB("sourceB/3");
    commit = getTestEKBCommit().addInsert(eo);
    persist.commit(commit);

    SourceModelA source = query.getModel(SourceModelA.class, getModelOid("sourceA/3"));
    source.setName("updatedNameA");
    commit = getTestEKBCommit().addUpdate(source);
    persist.commit(commit);

    eo = query.getModel(EOModel.class, getModelOid("eo/3"));
    assertThat(eo.getNameA(), is("updatedNameA"));
  }
Пример #2
0
  @Test
  public void
      testIfEngineeringObjectsAreInsertedCorrectly_shouldInsertObjectAndLoadReferencedValues()
          throws Exception {
    SourceModelA sourceA = new SourceModelA();
    sourceA.setEdbId("sourceA/1");
    sourceA.setName("sourceNameA");
    SourceModelB sourceB = new SourceModelB();
    sourceB.setEdbId("sourceB/1");
    sourceB.setName("sourceNameB");
    EKBCommit commit = getTestEKBCommit().addInsert(sourceA).addInsert(sourceB);
    persist.commit(commit);

    EOModel eo = new EOModel();
    eo.setEdbId("eo/1");
    eo.setRefModelA("sourceA/1");
    eo.setRefModelB("sourceB/1");
    commit = getTestEKBCommit().addInsert(eo);
    persist.commit(commit);

    EOModel result = query.getModel(EOModel.class, getModelOid("eo/1"));
    String nameA = result.getNameA();
    String nameB = result.getNameB();

    assertThat(nameA, is(sourceA.getName()));
    assertThat(nameB, is(sourceB.getName()));
  }
Пример #3
0
  @Test
  public void testIfEOUpdateWorksCorrectlyWithOnlyOneSource_shouldUpdateSourceModel()
      throws Exception {
    SourceModelA sourceA = new SourceModelA();
    sourceA.setEdbId("sourceA/4");
    sourceA.setName("sourceNameA");
    EKBCommit commit = getTestEKBCommit().addInsert(sourceA);
    persist.commit(commit);

    EOModel eo = new EOModel();
    eo.setEdbId("eo/4");
    eo.setRefModelA("sourceA/4");
    commit = getTestEKBCommit().addInsert(eo);
    persist.commit(commit);

    eo = query.getModel(EOModel.class, getModelOid("eo/4"));
    eo.setNameA("updatedNameA");
    commit = getTestEKBCommit().addUpdate(eo);
    persist.commit(commit);

    SourceModelA result = query.getModel(SourceModelA.class, getModelOid("sourceA/4"));
    assertThat(result.getName(), is("updatedNameA"));
  }