From 7b63b8eea09d906fad2302af4984bdd7435eb84f Mon Sep 17 00:00:00 2001 From: Mikhail Golod Date: Thu, 3 Mar 2016 08:50:48 +0300 Subject: [PATCH] CreateTriggerTest fixes & refactoring --- .../createtrigger/CreateTriggerChange.java | 2 +- .../ora/createtrigger/CreateTriggerTest.java | 45 ++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/main/java/liquibase/ext/ora/createtrigger/CreateTriggerChange.java b/src/main/java/liquibase/ext/ora/createtrigger/CreateTriggerChange.java index f0bb808..f6ebcc0 100644 --- a/src/main/java/liquibase/ext/ora/createtrigger/CreateTriggerChange.java +++ b/src/main/java/liquibase/ext/ora/createtrigger/CreateTriggerChange.java @@ -163,7 +163,7 @@ public void setProcedure(String procedure) { } public String getConfirmationMessage() { - return "Trigger" + getTriggerName() + " has been created"; + return "Trigger " + getTriggerName() + " has been created"; } protected Change[] createInverses() { diff --git a/src/test/java/liquibase/ext/ora/createtrigger/CreateTriggerTest.java b/src/test/java/liquibase/ext/ora/createtrigger/CreateTriggerTest.java index a35dea1..194560b 100644 --- a/src/test/java/liquibase/ext/ora/createtrigger/CreateTriggerTest.java +++ b/src/test/java/liquibase/ext/ora/createtrigger/CreateTriggerTest.java @@ -38,11 +38,11 @@ public void setUp() throws Exception { @Test public void getChangeMetaData() { - CreateTriggerChange addPrimaryKeyChange = new CreateTriggerChange(); + CreateTriggerChange createTriggerChange = new CreateTriggerChange(); - assertEquals("createTrigger", ChangeFactory.getInstance().getChangeMetaData(addPrimaryKeyChange).getName()); - assertEquals("Create Trigger", ChangeFactory.getInstance().getChangeMetaData(addPrimaryKeyChange).getDescription()); - assertEquals(ChangeMetaData.PRIORITY_DEFAULT, ChangeFactory.getInstance().getChangeMetaData(addPrimaryKeyChange).getPriority()); + assertEquals("createTrigger", ChangeFactory.getInstance().getChangeMetaData(createTriggerChange).getName()); + assertEquals("Create Trigger", ChangeFactory.getInstance().getChangeMetaData(createTriggerChange).getDescription()); + assertEquals(ChangeMetaData.PRIORITY_DEFAULT, ChangeFactory.getInstance().getChangeMetaData(createTriggerChange).getPriority()); } @Test @@ -50,7 +50,7 @@ public void getConfirmationMessage() { CreateTriggerChange change = new CreateTriggerChange(); change.setTriggerName("TRIGGER_NAME"); - assertEquals("Trigger TRIGGER_NAME has been created", "Trigger " + change.getTriggerName() + " has been created"); + assertEquals("Trigger TRIGGER_NAME has been created", change.getConfirmationMessage()); } @Test @@ -81,23 +81,24 @@ public void generateStatement() { assertEquals(1, sqlStatements.length); assertTrue(sqlStatements[0] instanceof CreateTriggerStatement); - assertEquals("SCHEMA_NAME", ((CreateTriggerStatement) sqlStatements[0]).getSchemaName()); - assertEquals("TABLE_NAME", ((CreateTriggerStatement) sqlStatements[0]).getTableName()); - assertEquals("COLUMN_NAMES", ((CreateTriggerStatement) sqlStatements[0]).getColumnNames()); - assertEquals("TABLESPACE_NAME", ((CreateTriggerStatement) sqlStatements[0]).getTablespace()); - assertEquals("AFTER_BEFORE_INSTEADOF", ((CreateTriggerStatement) sqlStatements[0]).getAfterBeforeInsteadOf()); - assertEquals("NESTED_TABLE_COLUMN", ((CreateTriggerStatement) sqlStatements[0]).getNestedTableColumn()); - assertEquals("POCEDURE", ((CreateTriggerStatement) sqlStatements[0]).getProcedure()); - assertEquals("TRIGGER_NAME", ((CreateTriggerStatement) sqlStatements[0]).getTriggerName()); - assertEquals("VIEW_NAME", ((CreateTriggerStatement) sqlStatements[0]).getViewName()); - assertEquals("WHEN_CONDITION", ((CreateTriggerStatement) sqlStatements[0]).getWhenCondition()); - - assertTrue(((CreateTriggerStatement) sqlStatements[0]).getUpdate()); - assertTrue(((CreateTriggerStatement) sqlStatements[0]).getUpdateOf()); - assertTrue(((CreateTriggerStatement) sqlStatements[0]).getReplace()); - assertTrue(((CreateTriggerStatement) sqlStatements[0]).getDelete()); - assertTrue(((CreateTriggerStatement) sqlStatements[0]).getForEachRow()); - assertTrue(((CreateTriggerStatement) sqlStatements[0]).getInsert()); + CreateTriggerStatement sqlStatement = (CreateTriggerStatement) sqlStatements[0]; + assertEquals("SCHEMA_NAME", sqlStatement.getSchemaName()); + assertEquals("TABLE_NAME", sqlStatement.getTableName()); + assertEquals("COLUMN_NAMES", sqlStatement.getColumnNames()); + assertEquals("TABLESPACE_NAME", sqlStatement.getTablespace()); + assertEquals("AFTER_BEFORE_INSTEADOF", sqlStatement.getAfterBeforeInsteadOf()); + assertEquals("NESTED_TABLE_COLUMN", sqlStatement.getNestedTableColumn()); + assertEquals("POCEDURE", sqlStatement.getProcedure()); + assertEquals("TRIGGER_NAME", sqlStatement.getTriggerName()); + assertEquals("VIEW_NAME", sqlStatement.getViewName()); + assertEquals("WHEN_CONDITION", sqlStatement.getWhenCondition()); + + assertTrue(sqlStatement.getUpdate()); + assertTrue(sqlStatement.getUpdateOf()); + assertTrue(sqlStatement.getReplace()); + assertTrue(sqlStatement.getDelete()); + assertTrue(sqlStatement.getForEachRow()); + assertTrue(sqlStatement.getInsert()); } @Test