Skip to content

Commit

Permalink
fix for schrodinger tests from labs of training 101
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Apr 24, 2020
1 parent 09829ff commit 8eb5475
Show file tree
Hide file tree
Showing 23 changed files with 344 additions and 76 deletions.
Expand Up @@ -13,7 +13,9 @@
import java.io.InputStream;
import java.util.Properties;

import com.codeborne.selenide.Condition;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.ex.ElementNotFound;
import com.codeborne.selenide.testng.BrowserPerClass;

import com.evolveum.midpoint.schrodinger.component.AssignmentsTab;
Expand All @@ -23,6 +25,7 @@
import com.evolveum.midpoint.schrodinger.page.AssignmentHolderDetailsPage;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down Expand Up @@ -170,7 +173,19 @@ protected void importObject(File source, boolean overrideExistingObject, boolean
.clickImportFileButton()
.feedback();

Assert.assertTrue(feedback.isSuccess() || (ignoreWarning && feedback.isWarning()));
boolean isSuccess = false;
try {
isSuccess = feedback.isSuccess();
} catch (ElementNotFound e) {
if (!ignoreWarning) {
throw e;
}
// else ignoring exception but isSuccess is still false
}
if (!isSuccess && ignoreWarning) {
isSuccess = feedback.isWarning();
}
Assert.assertTrue(isSuccess);
}

protected void importObject(File source, boolean overrideExistingObject) {
Expand Down
Expand Up @@ -49,7 +49,7 @@ public void beforeClass() throws IOException {
super.beforeClass();
}

@Test
@Test(groups={"M3"})
public void test0301ViewingResources() throws Exception {
initTestDirectory(DIRECTORY_CURRENT_TEST);

Expand Down Expand Up @@ -143,7 +143,7 @@ public void test0301ViewingResources() throws Exception {
changeResourceAttribute(CSV_3_RESOURCE_NAME, ScenariosCommons.CSV_RESOURCE_ATTR_FILE_PATH, csv3TargetFile.getAbsolutePath(), true);
}

@Test(dependsOnMethods = {"test0301ViewingResources"})
@Test(dependsOnMethods = {"test0301ViewingResources"}, groups={"M3"})
public void test0302BasicProvisioning() {
UserPage user = basicPage.newUser();
user.selectTabBasic()
Expand Down Expand Up @@ -191,7 +191,7 @@ public void test0302BasicProvisioning() {
PrismForm<AccountPage> accountForm = showShadow(CSV_1_RESOURCE_NAME, "Login", "kirk")
.form();

Selenide.sleep(2000);
Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
Assert.assertTrue(accountForm.compareInputAttributeValue("fname", "Jim T."));

showUser("kirk")
Expand Down
Expand Up @@ -45,7 +45,7 @@ public class M4ProvisioningToResources extends AbstractLabTest {
private static final File CSV_3_RESOURCE_FILE_4_4 = new File(LAB_OBJECTS_DIRECTORY + "resources/localhost-csvfile-3-ldap-4-4.xml");


@Test
@Test(groups={"M4"}, dependsOnGroups={"M3"})
public void test0401BasicProvisioningToMultipleResources() {
importObject(CSV_1_RESOURCE_FILE,true);

Expand Down Expand Up @@ -181,7 +181,7 @@ public void test0401BasicProvisioningToMultipleResources() {
Assert.assertFalse(existShadow(CSV_2_RESOURCE_NAME, "Login", "kirk"));
}

@Test(dependsOnMethods = {"test0401BasicProvisioningToMultipleResources"})
@Test(dependsOnMethods = {"test0401BasicProvisioningToMultipleResources"}, groups={"M4"}, dependsOnGroups={"M3"})
public void test0402AddingMappings() {

importObject(CSV_1_RESOURCE_FILE_4_2,true);
Expand Down Expand Up @@ -216,7 +216,7 @@ public void test0402AddingMappings() {

}

@Test(dependsOnMethods = {"test0402AddingMappings"})
@Test(dependsOnMethods = {"test0402AddingMappings"}, groups={"M4"}, dependsOnGroups={"M3"})
public void test0403ModifyingExistingMappings() {
importObject(CSV_1_RESOURCE_FILE_4_3,true);

Expand Down Expand Up @@ -271,7 +271,7 @@ public void test0403ModifyingExistingMappings() {

}

@Test(dependsOnMethods = {"test0403ModifyingExistingMappings"})
@Test(dependsOnMethods = {"test0403ModifyingExistingMappings"}, groups={"M4"}, dependsOnGroups={"M3"})
public void test0404AddingANewAttribute() {
((PrismFormWithActionButtons<AbstractTableWithPrismView<ProjectionsTab<UserPage>>>)
((AbstractTableWithPrismView)showUser("kirk")
Expand Down
Expand Up @@ -60,7 +60,7 @@ public class M5AccountsAssignmentsAndRoles extends AbstractLabTest {
private static final File ARCHETYPE_EXTERNAL_FILE = new File(LAB_OBJECTS_DIRECTORY + "archetypes/archetype-external.xml");
private static final File SYSTEM_CONFIGURATION_FILE_5_7 = new File(LAB_OBJECTS_DIRECTORY + "systemConfiguration/system-configuration-5-7.xml");

@Test
@Test(groups={"M5"}, dependsOnGroups={"M4"})
public void test0501UsingRBAC() {
importObject(INTERNAL_EMPLOYEE_ROLE_FILE,true);
importObject(INCOGNITO_ROLE_FILE,true);
Expand Down Expand Up @@ -96,7 +96,7 @@ public void test0501UsingRBAC() {

}

@Test(dependsOnMethods = {"test0501UsingRBAC"})
@Test(dependsOnMethods = {"test0501UsingRBAC"}, groups={"M5"}, dependsOnGroups={"M4"})
public void test0502SegregationOfDuties() {
showUser("kirk").selectTabAssignments()
.clickAddAssignemnt()
Expand All @@ -115,7 +115,7 @@ public void test0502SegregationOfDuties() {
.isError();
}

@Test(dependsOnMethods = {"test0502SegregationOfDuties"})
@Test(dependsOnMethods = {"test0502SegregationOfDuties"}, groups={"M5"}, dependsOnGroups={"M4"})
public void test0504CreatingRoles() {
InducementsTab<AbstractRolePage> tab = basicPage.newRole()
.selectTabBasic()
Expand All @@ -140,7 +140,7 @@ public void test0504CreatingRoles() {
Utils.removeAssignments(showUser("kirk").selectTabAssignments(), "Too Many Secrets");
}

@Test(dependsOnMethods = {"test0504CreatingRoles"})
@Test(dependsOnMethods = {"test0504CreatingRoles"}, groups={"M5"}, dependsOnGroups={"M4"})
public void test0505DisableOnUnassign() {
importObject(CSV_1_RESOURCE_FILE_5_5,true);
changeResourceAttribute(CSV_1_RESOURCE_NAME, ScenariosCommons.CSV_RESOURCE_ATTR_FILE_PATH, csv1TargetFile.getAbsolutePath(), true);
Expand Down Expand Up @@ -180,7 +180,7 @@ public void test0505DisableOnUnassign() {
Assert.assertTrue(accountForm.compareSelectAttributeValue("administrativeStatus", "Enabled"));
}

@Test(dependsOnMethods = {"test0505DisableOnUnassign"})
@Test(dependsOnMethods = {"test0505DisableOnUnassign"}, groups={"M5"}, dependsOnGroups={"M4"})
public void test0506InactiveAssignment() {
Utils.addAsignments(showUser("kirk").selectTabAssignments(), "Too Many Secrets");
AccountPage shadow = showShadow(CSV_1_RESOURCE_NAME, "Login", "jkirk");
Expand Down Expand Up @@ -226,7 +226,7 @@ public void test0506InactiveAssignment() {
Utils.removeAssignments(showUser("kirk").selectTabAssignments(), "Too Many Secrets");
}

@Test(dependsOnMethods = {"test0506InactiveAssignment"})
@Test(dependsOnMethods = {"test0506InactiveAssignment"}, groups={"M5"}, dependsOnGroups={"M4"})
public void test0507ArchetypesIntroduction() {

importObject(ARCHETYPE_EMPLOYEE_FILE, true);
Expand Down
Expand Up @@ -15,9 +15,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.io.File;
import java.io.IOException;

/**
* @author skublik
Expand All @@ -34,7 +36,7 @@ public class M6ConfiguringMultipleAccountTypes extends AbstractLabTest {
private static final String CSV1_TESTER_ROLE_NAME = "CSV-1 Tester";
private static final String CSV3_ADMIN_ROLE_NAME = "CSV-3 Admin";

@Test
@Test(groups={"M6"}, dependsOnGroups={"M5"})
public void test0601UsingAccountIntentsForProvisioning() {

importObject(CSV_1_RESOURCE_FILE_6_1,true);
Expand Down
Expand Up @@ -34,7 +34,7 @@ public class M7SynchronizationFlavours extends AbstractLabTest{

private static final Logger LOG = LoggerFactory.getLogger(M7SynchronizationFlavours.class);

@Test
@Test(groups={"M7"}, dependsOnGroups={"M6"})
public void test0701RunningImportFromResource() throws IOException {
hrTargetFile = new File(csvTargetDir, HR_FILE_SOURCE_NAME);
FileUtils.copyFile(HR_SOURCE_FILE, hrTargetFile);
Expand Down Expand Up @@ -87,7 +87,7 @@ public void test0701RunningImportFromResource() throws IOException {
Assert.assertEquals(basicPage.listUsers(ARCHETYPE_EMPLOYEE_PLURAL_LABEL).getCountOfObjects(), 15);
}

@Test(dependsOnMethods = {"test0701RunningImportFromResource"})
@Test(dependsOnMethods = {"test0701RunningImportFromResource"}, groups={"M7"}, dependsOnGroups={"M6"})
public void test0702RunningAccountReconciliation() {
Selenide.sleep(MidPoint.TIMEOUT_MEDIUM_6_S);
createReconTask("CSV-1 Reconciliation", CSV_1_RESOURCE_NAME);
Expand All @@ -109,7 +109,7 @@ public void test0702RunningAccountReconciliation() {
Assert.assertTrue(containsProjection("X001212", CSV_3_RESOURCE_OID, "cn=John Smith,ou=ExAmPLE,dc=example,dc=com"));
}

@Test(dependsOnMethods = {"test0702RunningAccountReconciliation"})
@Test(dependsOnMethods = {"test0702RunningAccountReconciliation"}, groups={"M7"}, dependsOnGroups={"M6"})
public void test0703RunningAttributeReconciliation() throws IOException {
FileUtils.copyFile(CSV_1_SOURCE_FILE_7_3, csv1TargetFile);

Expand All @@ -126,7 +126,7 @@ public void test0703RunningAttributeReconciliation() throws IOException {

}

@Test(dependsOnMethods = {"test0703RunningAttributeReconciliation"})
@Test(dependsOnMethods = {"test0703RunningAttributeReconciliation"}, groups={"M7"}, dependsOnGroups={"M6"})
public void test0704RunningLiveSync() throws IOException {
Selenide.sleep(MidPoint.TIMEOUT_MEDIUM_6_S);
TaskPage task = basicPage.newTask();
Expand All @@ -141,6 +141,11 @@ public void test0704RunningLiveSync() throws IOException {
.editRefValue("objectRef")
.selectType("Resource")
.table()
.search()
.byName()
.inputValue(HR_RESOURCE_NAME)
.updateSearch()
.and()
.clickByName(HR_RESOURCE_NAME)
.and()
.and()
Expand Down Expand Up @@ -214,6 +219,11 @@ private void createReconTask(String reconTaskName, String resource){
.editRefValue("objectRef")
.selectType("Resource")
.table()
.search()
.byName()
.inputValue(resource)
.updateSearch()
.and()
.clickByName(resource)
.and()
.and()
Expand Down
Expand Up @@ -61,7 +61,7 @@ protected void springTestContextPrepareTestInstance() throws Exception {
super.springTestContextPrepareTestInstance();
}

@Test
@Test(groups={"M8"}, dependsOnGroups={"M7"})
public void test0801ExtendingMidPointXMLSchema() {
PrismForm<AssignmentHolderBasicTab<UserPage>> form = basicPage.newUser()
.selectTabBasic()
Expand All @@ -80,6 +80,11 @@ public void test0801ExtendingMidPointXMLSchema() {
Selenide.sleep(MidPoint.TIMEOUT_DEFAULT_2_S);
ResourceAccountsTab<ViewResourcePage> accountTab = basicPage.listResources()
.table()
.search()
.byName()
.inputValue(HR_RESOURCE_NAME)
.updateSearch()
.and()
.clickByName(HR_RESOURCE_NAME)
.clickAccountsTab()
.clickSearchInResource();
Expand Down

0 comments on commit 8eb5475

Please sign in to comment.