@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) { } }
@Test public void testRemoveInstance() { try { assertEquals(3, applicationElement.getInstances("*").getCount()); InstanceElement ie = applicationElement.createInstance("new_instance"); assertEquals(4, applicationElement.getInstances("*").getCount()); assertEquals(ie.getName(), applicationElement.getInstanceByName("new_instance").getName()); applicationElement.removeInstance(ie.getId(), false); assertEquals(3, applicationElement.getInstances("*").getCount()); assertEquals(null, applicationElement.getInstanceByName("new_instance")); } catch (AoException e) { fail(e.reason); } // non existing instance try { applicationElement.removeInstance(ODSHelper.asODSLongLong(999), false); fail("AoException expected"); } catch (AoException e) { } }