Ejemplo n.º 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"));
  }
Ejemplo n.º 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()));
  }