Skip to content

Commit

Permalink
dbobject tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seed-master committed Sep 8, 2023
1 parent 6065055 commit 4536b54
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 15 deletions.
16 changes: 10 additions & 6 deletions src/main/java/org/seed/core/data/dbobject/DBObjectValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,43 @@ 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");

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());
Expand All @@ -53,7 +78,7 @@ void testDeleteSequence() {
}

@Test
@Order(3)
@Order(5)
void testDeleteProcedure() {
WebElement tabpanel = showDBObject("testprocedurenew");
assertEquals("Datenbankelemente: TestprocedureNew", findTab("datenbankelemente").getText());
Expand All @@ -65,7 +90,7 @@ void testDeleteProcedure() {
}

@Test
@Order(4)
@Order(6)
void testDeleteFunction() {
WebElement tabpanel = showDBObject("testfunctionnew");
assertEquals("Datenbankelemente: TestfunctionNew", findTab("datenbankelemente").getText());
Expand All @@ -77,7 +102,7 @@ void testDeleteFunction() {
}

@Test
@Order(5)
@Order(7)
void testDeleteTrigger() {
WebElement tabpanel = showDBObject("testtrigger");
assertEquals("Datenbankelemente: Testtrigger", findTab("datenbankelemente").getText());
Expand All @@ -89,7 +114,7 @@ void testDeleteTrigger() {
}

@Test
@Order(6)
@Order(8)
void testDeleteTriggerFunction() {
WebElement tabpanel = showDBObject("triggerfunction");
assertEquals("Datenbankelemente: Triggerfunction", findTab("datenbankelemente").getText());
Expand Down
60 changes: 56 additions & 4 deletions src/test/java/org/seed/test/integration/data/EditDBObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -89,7 +141,7 @@ void testFailRenameViewFunction() {
}

@Test
@Order(5)
@Order(8)
void testFailRenameTriggerFunction() {
WebElement tabpanel = showDBObject("triggerfunction");
assertEquals("Datenbankelemente: Triggerfunction", findTab("datenbankelemente").getText());
Expand Down

0 comments on commit 4536b54

Please sign in to comment.