public void test_can_rename_state() throws NameAlreadyBoundException, InvalidActionLanguageSyntaxException { String stateName = "State1"; String newStateName = "State2"; EntityDomain domain = new EntityDomain("TestDomain"); EntityClass klass = new EntityClass("Class"); domain.addClass(klass); EntityState newState = new EntityState(stateName); klass.addState(newState); EditorCommand_RenameState command = new EditorCommand_RenameState(); command.setDomain(domain); command.setStateId(stateName); command.setNewStateName(newStateName); command.setClassId("Class"); Assert.assertEquals(false, klass.hasStateWithName(newStateName)); Assert.assertEquals(true, klass.hasStateWithName(stateName)); Assert.assertEquals(true, command.canDoCommand().returnStatus()); Assert.assertEquals(true, command.doCommand().returnStatus()); Assert.assertEquals(true, klass.hasStateWithName(newStateName)); Assert.assertEquals(false, klass.hasStateWithName(stateName)); }
public void test_cant_rename_state_where_class_not_found() throws NameAlreadyBoundException { String stateName = "State1"; EntityDomain domain = new EntityDomain("TestDomain"); EditorCommand_RenameState command = new EditorCommand_RenameState(); command.setDomain(domain); command.setStateId(stateName); command.setNewStateName(stateName); command.setClassId("Class1"); Assert.assertEquals(false, command.canDoCommand().returnStatus()); Assert.assertEquals(false, command.doCommand().returnStatus()); }