From 6e6011d8b96a7b05f19a686bcaa76f7a38850c23 Mon Sep 17 00:00:00 2001 From: Fabian Peters Date: Sat, 14 Nov 2015 13:30:36 +0100 Subject: [PATCH] Enable use of ERMD2WListFilter for "ListMovie" page configuration and add functional tests. --- .../Resources/user.d2wmodel | 1 + .../Resources/user.d2wmodel.txt | 1 + .../er/modern/movies/test/ListFilterIT.java | 91 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 Tests/ERModernMoviesTest/Tests/er/modern/movies/test/ListFilterIT.java diff --git a/Tests/ERModernMoviesTest/Resources/user.d2wmodel b/Tests/ERModernMoviesTest/Resources/user.d2wmodel index bb30382fc4b..97d0fcf4a40 100644 --- a/Tests/ERModernMoviesTest/Resources/user.d2wmodel +++ b/Tests/ERModernMoviesTest/Resources/user.d2wmodel @@ -46,6 +46,7 @@ {"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "lhs" = {"class" = "com.webobjects.eocontrol.EOOrQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "pageConfiguration"; "selectorName" = "isLike"; "value" = "Edit*Movie"; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "pageConfiguration"; "selectorName" = "isLike"; "value" = "Inspect*Movie"; }); }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "subTask"; "value" = "tab"; }; }, {"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "lhs" = {"class" = "com.webobjects.eocontrol.EOAndQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "RuleIsDisabled"; "selectorName" = "isEqual"; "value" = "YES"; }, {"class" = "com.webobjects.eocontrol.EOAndQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "entity.name"; "selectorName" = "isEqualTo"; "value" = "Studio"; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "task"; "selectorName" = "isEqualTo"; "value" = "edit"; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "propertyKey"; "selectorName" = "isEqualTo"; "value" = "movies"; }); }); }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "componentName"; "value" = "ERMDEditRelationship"; }; }, {"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "lhs" = {"class" = "com.webobjects.eocontrol.EOAndQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "RuleIsDisabled"; "selectorName" = "isEqual"; "value" = "YES"; }, {"class" = "com.webobjects.eocontrol.EOAndQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "entity.name"; "selectorName" = "isEqualTo"; "value" = "Movie"; }, {"class" = "com.webobjects.eocontrol.EOOrQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "task"; "selectorName" = "isEqualTo"; "value" = "inspect"; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "task"; "selectorName" = "isEqualTo"; "value" = "edit"; }); }); }); }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "tabSectionsContents"; "value" = ("title", "plotSummary"); }; }, + {"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "lhs" = {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "pageConfiguration"; "selectorName" = "isEqualTo"; "value" = "ListMovie"; }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "searchKey"; "value" = ("title", "category", "revenue", "dateReleased", "plotSummary.summary"); }; }, {"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "documentation" = "This rule is not necessary, but something like it can be used if you wish to overide the default Embedded configuration name based on say, propertyKey. ie: You wish to differentiate between multiple relationships with the same destination entity name."; "lhs" = {"class" = "com.webobjects.eocontrol.EOAndQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "RuleIsDisabled"; "selectorName" = "isEqual"; "value" = "YES"; }, {"class" = "com.webobjects.eocontrol.EOAndQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "entity.name"; "selectorName" = "isEqualTo"; "value" = "Studio"; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "task"; "selectorName" = "isEqualTo"; "value" = "edit"; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "propertyKey"; "selectorName" = "isEqualTo"; "value" = "movies"; }); }); }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "listConfigurationName"; "value" = "ListEmbeddedFooMovie"; }; }, {"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "lhs" = {"class" = "com.webobjects.eocontrol.EOAndQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "smartRelationship"; "selectorName" = "isNotEqualTo"; "value" = {"class" = "com.webobjects.foundation.NSKeyValueCoding$Null"; }; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "smartRelationship.isToMany"; "selectorName" = "isEqualTo"; "value" = {"class" = "java.lang.Number"; "value" = "0"; }; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "task"; "selectorName" = "isEqualTo"; "value" = "inspect"; }); }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "componentName"; "value" = "ERD2WDisplayToOne"; }; }, {"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "documentation" = "Specify the display property keys for a given embedded configuration."; "lhs" = {"class" = "com.webobjects.eocontrol.EOAndQualifier"; "qualifiers" = ({"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "pageConfiguration"; "selectorName" = "isEqualTo"; "value" = "ListEmbeddedMovie"; }, {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "parentPageConfiguration"; "selectorName" = "isLike"; "value" = "*Studio"; }); }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "displayPropertyKeys"; "value" = ("title", "category", "rated"); }; }, diff --git a/Tests/ERModernMoviesTest/Resources/user.d2wmodel.txt b/Tests/ERModernMoviesTest/Resources/user.d2wmodel.txt index 0a1885135d6..4996629e541 100644 --- a/Tests/ERModernMoviesTest/Resources/user.d2wmodel.txt +++ b/Tests/ERModernMoviesTest/Resources/user.d2wmodel.txt @@ -45,6 +45,7 @@ 100 : (pageConfiguration like 'Edit*Movie' or pageConfiguration like 'Inspect*Movie') => subTask = "tab" [com.webobjects.directtoweb.Assignment], 100 : (entity.name = 'Studio' and task = 'edit' and propertyKey = 'movies') => componentName = "ERMDEditRelationship" [com.webobjects.directtoweb.Assignment], 100 : (entity.name = 'Movie' and (task = 'inspect' or task = 'edit')) => tabSectionsContents = ("title", "plotSummary") [com.webobjects.directtoweb.Assignment], + 100 : pageConfiguration = 'ListMovie' => searchKey = ("title", "category", "revenue", "dateReleased", "plotSummary.summary") [com.webobjects.directtoweb.Assignment], 100 : (entity.name = 'Studio' and task = 'edit' and propertyKey = 'movies') => listConfigurationName = "ListEmbeddedFooMovie" [com.webobjects.directtoweb.Assignment], 100 : (smartRelationship != null and smartRelationship.isToMany = 0 and task = 'inspect') => componentName = "ERD2WDisplayToOne" [com.webobjects.directtoweb.Assignment], 100 : (pageConfiguration = 'ListEmbeddedMovie' and parentPageConfiguration like '*Studio') => displayPropertyKeys = ("title", "category", "rated") [com.webobjects.directtoweb.Assignment], diff --git a/Tests/ERModernMoviesTest/Tests/er/modern/movies/test/ListFilterIT.java b/Tests/ERModernMoviesTest/Tests/er/modern/movies/test/ListFilterIT.java new file mode 100644 index 00000000000..2456e895bc4 --- /dev/null +++ b/Tests/ERModernMoviesTest/Tests/er/modern/movies/test/ListFilterIT.java @@ -0,0 +1,91 @@ +package er.modern.movies.test; + +import static com.codeborne.selenide.Condition.text; +import static com.codeborne.selenide.Condition.value; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$$; +import static com.codeborne.selenide.Selenide.open; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.codeborne.selenide.Condition; + +public class ListFilterIT extends AbstractSelenideIT { + + @Test + public void filterByPartialTitleTest() { + open("/"); + $(By.linkText("Login")).click(); + // get list of all movies + $(By.linkText("Find")).click(); + $("input[type=search]").setValue("fiction"); + // verify "Pulp Fiction" is listed + $(".ListMovieObjTable").shouldHave(text("Pulp Fiction")); + // and that it is the only match + $$(".ListMovieObjTable tr.ObjRow").shouldHaveSize(1); + } + + @Test + public void filterByCategoryTest() { + open("/"); + $(By.linkText("Login")).click(); + // get list of all movies + $(By.linkText("Find")).click(); + $("input[type=search]").setValue("noir"); + // verify "Heathers" is listed + $(".ListMovieObjTable").shouldHave(text("Heathers")); + // and that it is one of 5 matches + $$(".ListMovieObjTable tr.ObjRow").shouldHaveSize(5); + } + + @Test + public void filterByPlotSummaryTest() { + open("/"); + $(By.linkText("Login")).click(); + // get list of all movies + $(By.linkText("Find")).click(); + $("input[type=search]").setValue("dark"); + // verify "Heathers" is listed + $(".ListMovieObjTable").shouldHave(text("Heathers")); + // and that it is one of 2 matches + $$(".ListMovieObjTable tr.ObjRow").shouldHaveSize(2); + $("input[type=search]").setValue("darkn"); + // verify "Apocalypse Now" is listed + $(".ListMovieObjTable").shouldHave(text("Apocalypse Now")); + // and that it is the only match + $$(".ListMovieObjTable tr.ObjRow").shouldHaveSize(1); + } + + @Test + public void filterByDateTest() { + open("/"); + $(By.linkText("Login")).click(); + // get list of all movies + $(By.linkText("Find")).click(); + $("input[type=search]").setValue("1987"); + // verify "The Untouchables" is listed + $(".ListMovieObjTable").shouldHave(text("The Untouchables")); + // and that it is one of 3 matches + $$(".ListMovieObjTable tr.ObjRow").shouldHaveSize(3); + $("input[type=search]").setValue("01/03/1987"); + // verify "The Untouchables" is listed + $(".ListMovieObjTable").shouldHave(text("The Untouchables")); + // and that it is the only match + $$(".ListMovieObjTable tr.ObjRow").shouldHaveSize(1); + } + + @Test + public void filterByRevenueTest() { + open("/"); + $(By.linkText("Login")).click(); + // get list of all movies + $(By.linkText("Find")).click(); + $("input[type=search]").setValue("400000"); + // verify "Jurassic Park" is listed + $(".ListMovieObjTable").shouldHave(text("Jurassic Park")); + // and that it is one of 5 matches + $$(".ListMovieObjTable tr.ObjRow").shouldHaveSize(5); + } + +} \ No newline at end of file