private void performDiagramTest( final NonRootModelElement element, int expectedGraphicalElementCount) { Model_c model = Model_c.ModelInstance( Ooaofgraphics.getInstance(element.getModelRoot().getId()), new ClassQueryInterface_c() { @Override public boolean evaluate(Object candidate) { return ((Model_c) candidate).getOoa_id().equals(element.Get_ooa_id()); } }); assertNotNull( "Could not locate diagram for element : " + element.getClass().getSimpleName(), model); // if the element is a package assert the Ooa type for the model if (element instanceof Package_c) { assertTrue( "Found a diagram representing a package with an improper ooa type.", model.getOoa_type() == Ooatype_c.Package); } GraphicalElement_c[] elements = GraphicalElement_c.getManyGD_GEsOnR1(model); assertEquals( "Did not find the expected graphical element count for : " + element.getClass().getSimpleName(), expectedGraphicalElementCount, elements.length); for (GraphicalElement_c ge : elements) { // if the represents value is a package assert the proper ooa type if (ge.getRepresents() instanceof Package_c) { assertTrue( "Found a graphical element representing a package with an improper ooa type.", ge.getOoa_type() == Ooatype_c.Package); } } }
/** * Performs a test (of the given identifying name) on the canvas and an associated tool by * injecting the given inputs, and comparing the final state of the associated tool with the * expected one given. */ public void performTest(String testID, Inputs inputs, int expectedState) throws Exception { this.testID = testID; try { // perform the inputs on the canvas inputs.perform(); Activepoller_c.Oneshot(); // test that the new current tool state is the given one // that was expected int currentState = inputs.getToolCurrentState(); assertTrue( "Expected State: " + expectedState + " got " + currentState, currentState == expectedState); validateOrGenerateResults( UITestingUtilities.getGraphicalEditorFor( (NonRootModelElement) canvas.getRepresents(), true), recordResults, true); } finally { // perform the given cleanup inputs on the canvas inputs.cleanup(); Activepoller_c.Oneshot(); } }