diff --git a/src/main/java/org/seed/core/data/dbobject/DBObjectValidator.java b/src/main/java/org/seed/core/data/dbobject/DBObjectValidator.java index 2559eddfe..356b093c0 100644 --- a/src/main/java/org/seed/core/data/dbobject/DBObjectValidator.java +++ b/src/main/java/org/seed/core/data/dbobject/DBObjectValidator.java @@ -97,18 +97,22 @@ else if (!isEmpty(dbObject.getName()) && errors.addNotContains(dbObject.getObjectName()); } } - if (errors.isEmpty()) { - if (dbObject.isEnabled()) { - validateObjectType(dbObject, errors); - } - validateSaveUsage(dbObject, errors); + validateSaveExt(dbObject, errors); + } + validate(errors); + } + + private void validateSaveExt(DBObject dbObject, ValidationErrors errors) + throws ValidationException { + if (dbObject.isEnabled()) { + validateObjectType(dbObject, errors); } if (errors.isEmpty() && dbObject.isEnabled() && (dbObject.isNew() || dbObject.getType().isEditable())) { testSQL(dbObject); } - validate(errors); + validateSaveUsage(dbObject, errors); } private void validateSaveUsage(DBObject dbObject, ValidationErrors errors) { diff --git a/src/test/java/org/seed/test/integration/data/CreateDBObjectTest.java b/src/test/java/org/seed/test/integration/data/CreateDBObjectTest.java index e58a6b440..ca8355f31 100644 --- a/src/test/java/org/seed/test/integration/data/CreateDBObjectTest.java +++ b/src/test/java/org/seed/test/integration/data/CreateDBObjectTest.java @@ -170,4 +170,26 @@ void testCreateSequence() { saveDBObject(tabpanel); } + @Test + @Order(7) + void testCreateViewInView() { + WebElement tabpanel = newDBObject(); + assertEquals("Datenbankelemente", findTab("datenbankelemente").getText()); + WebElement window = newDBObjectWindow(); + + findCombobox(window, "type").sendKeys("View"); + findCombobox(window, "module").sendKeys("Testmodule"); + clickButton(window, "create"); + + findTextbox(tabpanel, "name").sendKeys("TestviewInView"); + findIntbox(tabpanel, "order").sendKeys("1"); + findCodeMirror(tabpanel, "content", 1).sendKeys("* from testview"); + + clickButton(tabpanel, "save"); + findValidationMessage(); // order too low + + findIntbox(tabpanel, "order").sendKeys("0"); // "1" + "0" = 10 + saveDBObject(tabpanel); + } + } diff --git a/src/test/java/org/seed/test/integration/data/DeleteDBObjectTest.java b/src/test/java/org/seed/test/integration/data/DeleteDBObjectTest.java index 6f8650a71..51dc6a88f 100644 --- a/src/test/java/org/seed/test/integration/data/DeleteDBObjectTest.java +++ b/src/test/java/org/seed/test/integration/data/DeleteDBObjectTest.java @@ -30,7 +30,7 @@ public class DeleteDBObjectTest extends AbstractDBObjectTest { @Test @Order(1) - void testDeleteView() { + void testFailDeleteView() { WebElement tabpanel = showDBObject("testviewnew"); assertEquals("Datenbankelemente: TestviewNew", findTab("datenbankelemente").getText()); clickButton(tabpanel, "delete"); @@ -38,10 +38,35 @@ void testDeleteView() { WebElement dialogConfirm = findConfirmDialog(); confirm(dialogConfirm); waitConfirmDialogDisappear(); + findValidationMessage(); // still in use } @Test @Order(2) + void testDeleteViewInView() { + WebElement tabpanel = showDBObject("testviewinview"); + assertEquals("Datenbankelemente: TestviewInView", findTab("datenbankelemente").getText()); + clickButton(tabpanel, "delete"); + + WebElement dialogConfirm = findConfirmDialog(); + confirm(dialogConfirm); + waitConfirmDialogDisappear(); + } + + @Test + @Order(3) + void testDeleteView() { + WebElement tabpanel = showDBObject("testviewnew"); + assertEquals("Datenbankelemente: TestviewNew", findTab("datenbankelemente").getText()); + clickButton(tabpanel, "delete"); + + WebElement dialogConfirm = findConfirmDialog(); + confirm(dialogConfirm); + waitConfirmDialogDisappear(); + } + + @Test + @Order(4) void testDeleteSequence() { WebElement tabpanel = showDBObject("testsequence"); assertEquals("Datenbankelemente: Testsequence", findTab("datenbankelemente").getText()); @@ -53,7 +78,7 @@ void testDeleteSequence() { } @Test - @Order(3) + @Order(5) void testDeleteProcedure() { WebElement tabpanel = showDBObject("testprocedurenew"); assertEquals("Datenbankelemente: TestprocedureNew", findTab("datenbankelemente").getText()); @@ -65,7 +90,7 @@ void testDeleteProcedure() { } @Test - @Order(4) + @Order(6) void testDeleteFunction() { WebElement tabpanel = showDBObject("testfunctionnew"); assertEquals("Datenbankelemente: TestfunctionNew", findTab("datenbankelemente").getText()); @@ -77,7 +102,7 @@ void testDeleteFunction() { } @Test - @Order(5) + @Order(7) void testDeleteTrigger() { WebElement tabpanel = showDBObject("testtrigger"); assertEquals("Datenbankelemente: Testtrigger", findTab("datenbankelemente").getText()); @@ -89,7 +114,7 @@ void testDeleteTrigger() { } @Test - @Order(6) + @Order(8) void testDeleteTriggerFunction() { WebElement tabpanel = showDBObject("triggerfunction"); assertEquals("Datenbankelemente: Triggerfunction", findTab("datenbankelemente").getText()); diff --git a/src/test/java/org/seed/test/integration/data/EditDBObjectTest.java b/src/test/java/org/seed/test/integration/data/EditDBObjectTest.java index 79595103e..65cde85d8 100644 --- a/src/test/java/org/seed/test/integration/data/EditDBObjectTest.java +++ b/src/test/java/org/seed/test/integration/data/EditDBObjectTest.java @@ -59,22 +59,74 @@ void testEditFunction() { @Test @Order(3) - void testEditView() { + void testFailEditView() { WebElement tabpanel = showDBObject("testview"); assertEquals("Datenbankelemente: Testview", findTab("datenbankelemente").getText()); clearTextbox(tabpanel, "name"); findTextbox(tabpanel, "name").sendKeys("TestviewNew"); + + WebElement codeMirror = findCodeMirror(tabpanel, "content", 1); + codeMirror.sendKeys(repeatKey(Keys.BACK_SPACE, 23)); + codeMirror.sendKeys("name from transferabletestnew"); + + clickButton(tabpanel, "save"); + findValidationMessage(); // view is in use + } + + @Test + @Order(4) + void testDisableViewDependent() { + WebElement tabpanel = showDBObject("testviewinview"); + assertEquals("Datenbankelemente: TestviewInView", findTab("datenbankelemente").getText()); clearIntbox(tabpanel, "order"); - findIntbox(tabpanel, "order").sendKeys("4"); + findIntbox(tabpanel, "order").sendKeys("-1"); + + clickButton(tabpanel, "save"); + findValidationMessage(); // illegal order + + clearIntbox(tabpanel, "order"); + findIntbox(tabpanel, "order").sendKeys("0"); + saveDBObject(tabpanel); + } + + @Test + @Order(5) + void testEditView() { + WebElement tabpanel = showDBObject("testview"); + assertEquals("Datenbankelemente: Testview", findTab("datenbankelemente").getText()); + clearTextbox(tabpanel, "name"); + findTextbox(tabpanel, "name").sendKeys("TestviewNew"); WebElement codeMirror = findCodeMirror(tabpanel, "content", 1); codeMirror.sendKeys(repeatKey(Keys.BACK_SPACE, 23)); codeMirror.sendKeys("name,testfunctionnew() from transferabletestnew"); + clickButton(tabpanel, "save"); + findValidationMessage(); // order too low + + clearIntbox(tabpanel, "order"); + findIntbox(tabpanel, "order").sendKeys("4"); saveDBObject(tabpanel); } @Test - @Order(4) + @Order(6) + void testEnableViewDependent() { + WebElement tabpanel = showDBObject("testviewinview"); + assertEquals("Datenbankelemente: TestviewInView", findTab("datenbankelemente").getText()); + + WebElement codeMirror = findCodeMirror(tabpanel, "content", 1); + codeMirror.sendKeys("new"); + clearIntbox(tabpanel, "order"); + findIntbox(tabpanel, "order").sendKeys("1"); + clickButton(tabpanel, "save"); + findValidationMessage(); // order too low + + findIntbox(tabpanel, "order").sendKeys("0"); // "1" + "0" = 10 + saveDBObject(tabpanel); + } + + @Test + @Order(7) void testFailRenameViewFunction() { WebElement tabpanel = showDBObject("testfunctionnew"); assertEquals("Datenbankelemente: TestfunctionNew", findTab("datenbankelemente").getText()); @@ -89,7 +141,7 @@ void testFailRenameViewFunction() { } @Test - @Order(5) + @Order(8) void testFailRenameTriggerFunction() { WebElement tabpanel = showDBObject("triggerfunction"); assertEquals("Datenbankelemente: Triggerfunction", findTab("datenbankelemente").getText());