Skip to content

Commit

Permalink
schrodinger: more assertions refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jan 17, 2021
1 parent 63dc51d commit 9ffb9e4
Show file tree
Hide file tree
Showing 49 changed files with 272 additions and 221 deletions.
Expand Up @@ -10,7 +10,6 @@
import com.evolveum.midpoint.schrodinger.page.configuration.ImportObjectPage;

import org.apache.commons.io.FileUtils;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.io.File;
Expand Down
Expand Up @@ -11,13 +11,9 @@
import java.util.Arrays;
import java.util.List;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.evolveum.midpoint.schrodinger.component.AssignmentHolderBasicTab;
import com.evolveum.midpoint.schrodinger.component.DateTimePanel;
import com.evolveum.midpoint.schrodinger.component.common.DelegationDetailsPanel;
import com.evolveum.midpoint.schrodinger.component.common.PrismForm;
import com.evolveum.midpoint.schrodinger.page.login.FormLoginPage;
import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage;
import com.evolveum.midpoint.schrodinger.page.user.UserPage;
Expand Down Expand Up @@ -122,30 +118,27 @@ public void test0030createDelegationTest() {
.feedback()
.assertSuccess();

DelegationDetailsPanel delegationDetailsPanel = showUser("DelegateToUser")
showUser("DelegateToUser")
.selectTabDelegatedToMe()
.getDelegationDetailsPanel("DelegateFromUser")
.expandDetailsPanel("DelegateFromUser");
delegationDetailsPanel.assertAssignmentPrivilegesNotSelected();
delegationDetailsPanel.assertAssignmentLimitationsNotSelected();
delegationDetailsPanel.assertApprovalWorkItemsSelected();
delegationDetailsPanel.assertCertificationWorkItemsSelected();
.expandDetailsPanel("DelegateFromUser")
.assertAssignmentPrivilegesNotSelected()
.assertAssignmentLimitationsNotSelected()
.assertApprovalWorkItemsSelected()
.assertCertificationWorkItemsSelected()
.assertDescriptionDisabled()
.assertValidFromPanelDisabled();

Assert.assertFalse(delegationDetailsPanel.isDescriptionEnabled(), "Description should be disabled");
Assert.assertTrue(delegationDetailsPanel.isValidFromPanelDisabled(), "Valid from panel should be disabled");

DelegationDetailsPanel delegationDetailsFromUser = showUser("DelegateFromUser")
showUser("DelegateFromUser")
.selectTabDelegations()
.getDelegationDetailsPanel("DelegateToUser")
.expandDetailsPanel("DelegateToUser");

delegationDetailsFromUser.assertAssignmentPrivilegesNotSelected();
delegationDetailsFromUser.assertAssignmentLimitationsNotSelected();
delegationDetailsFromUser.assertApprovalWorkItemsSelected();
delegationDetailsFromUser.assertCertificationWorkItemsSelected();

Assert.assertFalse(delegationDetailsFromUser.isDescriptionEnabled(), "Description should be disabled");
Assert.assertTrue(delegationDetailsFromUser.isValidFromPanelDisabled(), "Valid from panel should be disabled");
.expandDetailsPanel("DelegateToUser")
.assertAssignmentPrivilegesNotSelected()
.assertAssignmentLimitationsNotSelected()
.assertApprovalWorkItemsSelected()
.assertCertificationWorkItemsSelected()
.assertDescriptionDisabled()
.assertValidFromPanelDisabled();
}

@Test
Expand Down
Expand Up @@ -13,7 +13,6 @@
import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage;
import com.evolveum.midpoint.schrodinger.page.user.UserPage;

import org.testng.Assert;
import org.testng.annotations.Test;

import java.io.File;
Expand Down
Expand Up @@ -8,7 +8,6 @@

import com.evolveum.midpoint.schrodinger.component.user.UsersPageTable;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.evolveum.midpoint.testing.schrodinger.AbstractSchrodingerTest;
Expand Down
Expand Up @@ -14,7 +14,6 @@

import com.evolveum.midpoint.schrodinger.component.DateTimePanel;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.evolveum.midpoint.schrodinger.component.common.search.Search;
Expand Down Expand Up @@ -105,16 +104,17 @@ public void test0010defaultSearchOnListPage() {
public void test0020addSearchAttributeByAddButtonClick() {
RolesPageTable table = basicPage.listRoles().table();
Search<RolesPageTable> search = (Search<RolesPageTable>) table.search();
search.addSearchItemByAddButtonClick(REQUESTABLE_ATTRIBUTE);
Assert.assertNotNull(search.textInputPanelByItemName(REQUESTABLE_ATTRIBUTE, false));
search.addSearchItemByAddButtonClick(REQUESTABLE_ATTRIBUTE)
.assertTextInputPanelByItemNameExist(REQUESTABLE_ATTRIBUTE, false);
}

@Test
public void test0030addSearchAttributeByNameLinkClick() {
ServicesPageTable table = basicPage.listServices().table();
Search<ServicesPageTable> search = (Search<ServicesPageTable>) table.search();
search.addSearchItemByNameLinkClick(ROLE_MEMBERSHIP_ATTRIBUTE);
Assert.assertNotNull(search.textInputPanelByItemName(ROLE_MEMBERSHIP_ATTRIBUTE, false));
search
.addSearchItemByNameLinkClick(ROLE_MEMBERSHIP_ATTRIBUTE)
.assertTextInputPanelByItemNameExist(ROLE_MEMBERSHIP_ATTRIBUTE, false);
}

@Test
Expand Down Expand Up @@ -186,9 +186,11 @@ public void test0080referenceAttributeByNameSearch() {
search.referencePanelByItemName(ROLE_MEMBERSHIP_ATTRIBUTE)
.inputRefName("roleMembershipByName", "roleMembershipByNameSearch")
.updateSearch();
table.assertTableObjectsCountEquals(1);
table.assertTableContainsLinkTextPartially("testUserWithRoleMembershipSearchByName");
Assert.assertTrue(search.referencePanelByItemName(ROLE_MEMBERSHIP_ATTRIBUTE).matchRefSearchFieldValue(REF_SEARCH_FIELD_VALUE));
table
.assertTableObjectsCountEquals(1)
.assertTableContainsLinkTextPartially("testUserWithRoleMembershipSearchByName");
search.referencePanelByItemName(ROLE_MEMBERSHIP_ATTRIBUTE)
.assertRefSearchFieldValueMatch(REF_SEARCH_FIELD_VALUE);
}

@Test
Expand Down
Expand Up @@ -263,9 +263,10 @@ public void mod10test03LookupTablesAndAttributeOverrides() {
.selectTabBasic()
.form();

form.showEmptyAttributes("Properties");
form.addAttributeValue("empStatus", "O");
form.addAttributeValue("familyName", "kirk2");
form
.showEmptyAttributes("Properties")
.addAttributeValue("empStatus", "O")
.addAttributeValue("familyName", "kirk2");
boolean existFeedback = false;
try { existFeedback = form.and().and().feedback().isError(); } catch (ElementNotFound e) { }
Assert.assertFalse(existFeedback);
Expand Down
Expand Up @@ -19,8 +19,6 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand Down
Expand Up @@ -23,7 +23,6 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

import org.apache.commons.io.FileUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -65,26 +64,20 @@ public void mod03test01ViewingResources() throws Exception {
// Password attribute name should be password
configTab.assertInputAttributeValueMatches(PASSWORD_ATTRIBUTE_NAME, CSV_1_PASSWORD_ATTRIBUTE_NAME);

ResourceWizardPage resourceWizard = basicPage.listResources()
SchemaStepSchemaTab schemaStepSchemaTab = basicPage.listResources()
.table()
.clickByName(CSV_1_RESOURCE_NAME)
.clickShowUsingWizard();

Assert.assertTrue(resourceWizard.isReadonlyMode());

//Configuration tab
Assert.assertTrue(resourceWizard.selectConfigurationStep().getParentElement().exists());

//Schema tab
SchemaStepSchemaTab schemaStepSchemaTab = resourceWizard
.selectSchemaStep()
.selectSchemaTab();
Assert.assertTrue(schemaStepSchemaTab.isObjectClassPresent(CSV_1_ACCOUNT_OBJECT_CLASS_LINK));

schemaStepSchemaTab.clickObjectClass(CSV_1_ACCOUNT_OBJECT_CLASS_LINK);
.clickShowUsingWizard()
.assertReadonlyMode()
.selectConfigurationStep()
.and()
.selectSchemaStep()
.selectSchemaTab()
.assertObjectClassPresent(CSV_1_ACCOUNT_OBJECT_CLASS_LINK)
.clickObjectClass(CSV_1_ACCOUNT_OBJECT_CLASS_LINK);
//check resource attributes are present
CSV_1_RESOURCE_ATTRIBUTES.forEach(attr ->
Assert.assertTrue(schemaStepSchemaTab.getAttributesTable().containsText(attr)));
schemaStepSchemaTab.getAttributesTable().assertTableContainsText(attr));

importObject(NUMERIC_PIN_FIRST_NONZERO_POLICY_FILE, true);

Expand Down
Expand Up @@ -26,7 +26,6 @@
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand Down
Expand Up @@ -37,7 +37,6 @@
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -154,9 +153,9 @@ public void mod05test04CreatingRoles() {
DirectIndirectAssignmentTable<AssignmentsTab<UserPage>> table = showUser("kirk").selectTabAssignments()
.selectTypeAllDirectIndirect();
Selenide.sleep(MidPoint.TIMEOUT_MEDIUM_6_S);
Assert.assertTrue(table.containsIndirectAssignments("Secret Projects I",
table.assertIndirectAssignmentsExist("Secret Projects I",
"Secret Projects II", "Top Secret Projects I", CSV_1_RESOURCE_NAME, CSV_2_RESOURCE_NAME,
CSV_3_RESOURCE_NAME));
CSV_3_RESOURCE_NAME);

Utils.removeAssignments(showUser("kirk").selectTabAssignments(), "Too Many Secrets");
}
Expand All @@ -177,9 +176,10 @@ public void mod05test05DisableOnUnassign() {
AccountPage shadow = showShadow(CSV_1_RESOURCE_NAME, "Login", "jkirk");
Selenide.sleep(2000);
PrismForm<AccountPage> accountForm = shadow.form();
accountForm.assertSelectAttributeValueMatches("administrativeStatus", "Disabled");
Assert.assertTrue(accountForm.showEmptyAttributes("Attributes")
.compareInputAttributeValues("groups", new ArrayList<String>()));
accountForm
.assertSelectAttributeValueMatches("administrativeStatus", "Disabled")
.showEmptyAttributes("Attributes")
.assertInputAttributeValuesMatches("groups", new ArrayList<String>());

showShadow(CSV_2_RESOURCE_NAME, "Login", "jkirk");
accountForm.assertSelectAttributeValueMatches("administrativeStatus", "Disabled");
Expand Down Expand Up @@ -231,9 +231,10 @@ public void mod05test06InactiveAssignment() {
Utils.setStatusForAssignment(showUser("kirk").selectTabAssignments(), "Internal Employee", "Disabled");

showShadow(CSV_1_RESOURCE_NAME, "Login", "jkirk");
accountForm.assertSelectAttributeValueMatches("administrativeStatus", "Disabled");
Assert.assertTrue(accountForm.showEmptyAttributes("Attributes")
.compareInputAttributeValues("groups", new ArrayList<String>()));
accountForm
.assertSelectAttributeValueMatches("administrativeStatus", "Disabled")
.showEmptyAttributes("Attributes")
.assertInputAttributeValuesMatches("groups", new ArrayList<String>());

showShadow(CSV_2_RESOURCE_NAME, "Login", "jkirk");
accountForm.assertSelectAttributeValueMatches("administrativeStatus", "Disabled");
Expand Down Expand Up @@ -284,7 +285,9 @@ public void mod05test07ArchetypesIntroduction() {

AssignmentsTab<UserPage> assigmentsTab = showUser("janeway")
.selectTabAssignments();
Assert.assertFalse(assigmentsTab.table().containsText(ARCHETYPE_EMPLOYEE_NAME));
assigmentsTab
.table()
.assertTableContainsText(ARCHETYPE_EMPLOYEE_NAME);
Utils.addAsignments(assigmentsTab, "Secret Projects I");
}
}
Expand Up @@ -11,6 +11,7 @@
import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.component.ProjectionsTab;
import com.evolveum.midpoint.schrodinger.component.common.table.AbstractTableWithPrismView;
import com.evolveum.midpoint.schrodinger.component.common.table.Table;
import com.evolveum.midpoint.schrodinger.component.resource.ResourceAccountsTab;
import com.evolveum.midpoint.schrodinger.page.resource.ViewResourcePage;
import com.evolveum.midpoint.schrodinger.page.task.TaskPage;
Expand All @@ -22,7 +23,6 @@
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -98,7 +98,7 @@ public void mod07test01RunningImportFromResource() throws IOException {
showTask("Initial import from HR")
.selectTabOperationStatistics()
.assertSuccessfullyProcessedCountMatch(14);
Assert.assertEquals(basicPage.listUsers(ARCHETYPE_EMPLOYEE_PLURAL_LABEL).getCountOfObjects(), 14);
basicPage.listUsers(ARCHETYPE_EMPLOYEE_PLURAL_LABEL).assertObjectsCountEquals(14);
}

@Test(dependsOnMethods = {"mod07test01RunningImportFromResource"}, groups={"M7"})
Expand All @@ -122,19 +122,19 @@ public void mod07test02RunningAccountReconciliation() throws IOException {
Selenide.sleep(MidPoint.TIMEOUT_SHORT_4_S);
deselectDryRun("CSV-1 Reconciliation");
Selenide.sleep(MidPoint.TIMEOUT_SHORT_4_S);
Assert.assertTrue(containsProjection("X001212", CSV_1_RESOURCE_OID, "jsmith"));
assertContainsProjection("X001212", CSV_1_RESOURCE_OID, "jsmith");

createReconTask("CSV-2 Reconciliation", CSV_2_RESOURCE_NAME);
Selenide.sleep(MidPoint.TIMEOUT_SHORT_4_S);
deselectDryRun("CSV-2 Reconciliation");
Selenide.sleep(MidPoint.TIMEOUT_SHORT_4_S);
Assert.assertTrue(containsProjection("X001212", CSV_2_RESOURCE_OID, "jsmith"));
assertContainsProjection("X001212", CSV_2_RESOURCE_OID, "jsmith");

createReconTask("CSV-3 Reconciliation", CSV_3_RESOURCE_NAME);
Selenide.sleep(MidPoint.TIMEOUT_SHORT_4_S);
deselectDryRun("CSV-3 Reconciliation");
Selenide.sleep(MidPoint.TIMEOUT_SHORT_4_S);
Assert.assertTrue(containsProjection("X001212", CSV_3_RESOURCE_OID, "cn=John Smith,ou=ExAmPLE,dc=example,dc=com"));
assertContainsProjection("X001212", CSV_3_RESOURCE_OID, "cn=John Smith,ou=ExAmPLE,dc=example,dc=com");
}

@Test(dependsOnMethods = {"mod07test02RunningAccountReconciliation"}, groups={"M7"})
Expand Down Expand Up @@ -219,7 +219,7 @@ public void mod07test04RunningLiveSync() throws IOException {

}

private boolean containsProjection(String user, String resourceOid, String accountName) {
private Table<ProjectionsTab<UserPage>> assertContainsProjection(String user, String resourceOid, String accountName) {
AbstractTableWithPrismView<ProjectionsTab<UserPage>> table = showUser(user).selectTabProjections().table();
Selenide.screenshot(user + "_" + resourceOid + "_" + accountName);
return table
Expand All @@ -228,7 +228,7 @@ private boolean containsProjection(String user, String resourceOid, String accou
.inputRefOid(resourceOid)
.updateSearch()
.and()
.containsText(accountName);
.assertTableContainsText(accountName);
}

private void createReconTask(String reconTaskName, String resource){
Expand Down
Expand Up @@ -14,10 +14,8 @@

import com.evolveum.midpoint.schrodinger.page.resource.AccountPage;
import com.evolveum.midpoint.testing.schrodinger.scenarios.ScenariosCommons;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;

import org.apache.commons.io.FileUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -58,23 +56,23 @@ public void mod09test01ImportStaticOrgStructure() {
importObject(ORG_EXAMPLE_FILE, true);

OrgTreePage orgTree = basicPage.orgStructure();
Assert.assertTrue(orgTree.selectTabWithRootOrg("ExAmPLE, Inc. - Functional Structure")
orgTree.selectTabWithRootOrg("ExAmPLE, Inc. - Functional Structure")
.getOrgHierarchyPanel()
.showTreeNodeDropDownMenu("ExAmPLE, Inc. - Functional Structure")
.expandAll()
.expandOrg("Software Department")
.containsChildOrg("ExAmPLE, Inc. - Functional Structure", "Executive Division", "Sales Department",
"Human Resources", "Technology Division", "IT Administration Department", "Software Department", "Java Development"));
Assert.assertTrue(orgTree.selectTabWithRootOrg("Groups")
.assertChildOrgExists("ExAmPLE, Inc. - Functional Structure", "Executive Division", "Sales Department",
"Human Resources", "Technology Division", "IT Administration Department", "Software Department", "Java Development");
orgTree.selectTabWithRootOrg("Groups")
.getOrgHierarchyPanel()
.containsChildOrg("Groups", "Active Employees", "Administrators", "Contractors", "Former Employees",
"Inactive Employees", "Security"));
.assertChildOrgExists("Groups", "Active Employees", "Administrators", "Contractors", "Former Employees",
"Inactive Employees", "Security");

importObject(ORG_SECRET_OPS_FILE, true);
Assert.assertTrue(basicPage.orgStructure()
basicPage.orgStructure()
.selectTabWithRootOrg("ExAmPLE, Inc. - Functional Structure")
.getOrgHierarchyPanel()
.containsChildOrg("Secret Operations", "Transportation and Logistics Department"));
.assertChildOrgExists("Secret Operations", "Transportation and Logistics Department");
}

@Test(dependsOnMethods = {"mod09test01ImportStaticOrgStructure"})
Expand Down Expand Up @@ -289,9 +287,9 @@ public void mod09test03OrganizationActingAsARole() {
.assertInputAttributeValuesMatches("groups", "Internal Employees", "Essential Documents",
"Teleportation", "Time Travel", "Lucky Numbers", "Presidential Candidates Motivation");

Assert.assertTrue(showUser("kirk").selectTabAssignments()
showUser("kirk").selectTabAssignments()
.selectTypeAllDirectIndirect()
.containsIndirectAssignments("Secret Projects II"));
.assertIndirectAssignmentsExist("Secret Projects II");
}

}
Expand Up @@ -6,8 +6,6 @@
*/
package com.evolveum.midpoint.testing.schrodinger.page;

import com.codeborne.selenide.Selenide;

import com.evolveum.midpoint.schrodinger.page.configuration.AboutPage;
import com.evolveum.midpoint.testing.schrodinger.AbstractSchrodingerTest;
import org.testng.Assert;
Expand Down

0 comments on commit 9ffb9e4

Please sign in to comment.