@Test public void testGetAllRelations() { try { ApplicationElement ae = applicationElement.getApplicationStructure().getElementByName("prj"); assertEquals(2, ae.getAllRelations().length); ApplicationRelation firstRel = ae.getAllRelations()[0]; assertEquals("env_iid", firstRel.getRelationName()); assertEquals("prj_iid", firstRel.getInverseRelationName()); assertEquals("environment", firstRel.getBaseRelation().getRelationName()); assertEquals("tests", firstRel.getBaseRelation().getInverseRelationName()); assertEquals(RelationType.FATHER_CHILD, firstRel.getRelationType()); assertEquals(0, firstRel.getRelationRange().min); assertEquals(1, firstRel.getRelationRange().max); assertEquals(0, firstRel.getInverseRelationRange().min); assertEquals(-1, firstRel.getInverseRelationRange().max); assertEquals(Relationship.FATHER, firstRel.getRelationship()); assertEquals(Relationship.CHILD, firstRel.getInverseRelationship()); ApplicationRelation secRel = ae.getAllRelations()[1]; assertEquals("tstser_iid", secRel.getRelationName()); assertEquals("prj_iid", secRel.getInverseRelationName()); assertEquals("children", secRel.getBaseRelation().getRelationName()); assertEquals("parent_test", secRel.getBaseRelation().getInverseRelationName()); assertEquals(RelationType.FATHER_CHILD, secRel.getRelationType()); assertEquals(0, secRel.getRelationRange().min); assertEquals(-1, secRel.getRelationRange().max); assertEquals(1, secRel.getInverseRelationRange().min); assertEquals(1, secRel.getInverseRelationRange().max); } catch (AoException e) { fail(e.reason); } }
@Test public void testSetName() { try { assertEquals("dts", applicationElement.getName()); applicationElement.setName("new_name"); assertEquals( "new_name", applicationElement.getApplicationStructure().getElementByName("new_name").getName()); applicationElement.setName("dts"); assertEquals("dts", applicationElement.getName()); } catch (AoException e) { fail(e.reason); } // empty attribute name try { applicationElement.setName(""); fail("AoException expected"); } catch (AoException e) { assertEquals(ErrorCode.AO_BAD_PARAMETER, e.errCode); } // name length > 30 try { applicationElement.setName("012345678901234567890123456789x"); fail("AoException expected"); } catch (AoException e) { assertEquals(ErrorCode.AO_BAD_PARAMETER, e.errCode); } // duplicate application element name try { applicationElement.setName("mea"); fail("AoException expected"); } catch (AoException e) { assertEquals(ErrorCode.AO_DUPLICATE_NAME, e.errCode); } }
@Test public void testGetApplicationStructure() { try { applicationElement.getApplicationStructure(); } catch (AoException e) { fail(e.reason); } }
@Test public void testGetInstanceByName() { try { InstanceElement ie = applicationElement.getInstanceByName("1/3 Octave - Zusammenfassung"); assertEquals(58, ODSHelper.asJLong(ie.getId())); ie = applicationElement.getInstanceByName("not existing instance"); assertEquals(null, ie); } catch (AoException e) { fail(e.reason); } // check duplicate names try { ApplicationElement aeParamSet = applicationElement.getApplicationStructure().getElementByName("pas"); aeParamSet.getInstanceByName("basic"); fail("AoException expected"); } catch (AoException e) { } }