-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sc-13165] Testing the framework (#5)
* Removed BasicWebTest: The suite is run using a shell script which invokes the JAR * Cleanup unused experiments * Add Helper Tests * Removed shade-y warnings * Fix org.junit.jupiter.junit-jupiter at 5.11.0 * Add Period tests * Clean up * Remove unused pom lines * Remove lint test
- Loading branch information
Showing
11 changed files
with
179 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,5 +185,4 @@ private String handleResponse(CloseableHttpResponse response) throws Exception { | |
} | ||
return responseBody; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,5 +337,4 @@ public Map<String, String> convertMetadata(Map<String, String> inputData, String | |
|
||
return returnMap; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,4 @@ public final class TestUniqueId { | |
public String get() { | ||
return testUniqueId; | ||
} | ||
|
||
} |
31 changes: 0 additions & 31 deletions
31
...CucumberTestTool/src/main/java/org/rtsl/dhis2/cucumber/definitions/Dhis2BasicWebTest.java
This file was deleted.
Oops, something went wrong.
66 changes: 20 additions & 46 deletions
66
rtsl_util/CommonUtils/Dhis2CucumberTestTool/src/main/resources/spring.android.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:sec="http://www.springframework.org/schema/security" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xmlns:util="http://www.springframework.org/schema/util" | ||
xmlns:tx="http://www.springframework.org/schema/tx" | ||
xmlns:task="http://www.springframework.org/schema/task" | ||
xsi:schemaLocation=" | ||
http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd | ||
http://www.springframework.org/schema/context | ||
http://www.springframework.org/schema/context/spring-context-3.1.xsd | ||
http://www.springframework.org/schema/security | ||
http://www.springframework.org/schema/security/spring-security-3.1.xsd | ||
http://www.springframework.org/schema/util | ||
http://www.springframework.org/schema/util/spring-util-3.1.xsd | ||
http://www.springframework.org/schema/tx | ||
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | ||
http://www.springframework.org/schema/task | ||
http://www.springframework.org/schema/task/spring-task.xsd | ||
"> | ||
|
||
|
||
|
||
|
||
<bean id="mobileDesiredCapabilities" class="org.openqa.selenium.remote.DesiredCapabilities"> | ||
<constructor-arg> | ||
<util:map> | ||
<entry key="platformName" value="Android" /> | ||
<entry key="platformVersion" value="8.0" /> | ||
<entry key="app" value="/Users/test/Downloads/FirstAutomationTest/src/test/resources/DemoApp.apk" /> | ||
<entry key="deviceName" value="c4e3f3cd" /> | ||
<entry key="automationName" value="UiAutomator2" /> | ||
</util:map> | ||
</constructor-arg> | ||
</bean> | ||
|
||
|
||
<!-- | ||
<bean id="androidDriver" class="io.appium.java_client.android.AndroidDriver" > | ||
<constructor-arg value="http://127.0.0.1:4723/" /> | ||
<constructor-arg ref="mobileDesiredCapabilities" /> | ||
</bean> | ||
--> | ||
xmlns:sec="http://www.springframework.org/schema/security" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xmlns:util="http://www.springframework.org/schema/util" | ||
xmlns:tx="http://www.springframework.org/schema/tx" | ||
xmlns:task="http://www.springframework.org/schema/task" | ||
xsi:schemaLocation=" | ||
http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd | ||
http://www.springframework.org/schema/context | ||
http://www.springframework.org/schema/context/spring-context-3.1.xsd | ||
http://www.springframework.org/schema/security | ||
http://www.springframework.org/schema/security/spring-security-3.1.xsd | ||
http://www.springframework.org/schema/util | ||
http://www.springframework.org/schema/util/spring-util-3.1.xsd | ||
http://www.springframework.org/schema/tx | ||
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | ||
http://www.springframework.org/schema/task | ||
http://www.springframework.org/schema/task/spring-task.xsd | ||
"> | ||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../CommonUtils/Dhis2CucumberTestTool/src/test/java/org/rtsl/dhis2/cucumber/HelperTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.rtsl.dhis2.cucumber; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class HelperTests { | ||
@Test | ||
public void testToISODateTimeString() throws Exception { | ||
String actual = Helper.toISODateTimeString("2021-01-01"); | ||
|
||
Assertions.assertEquals("2021-01-01T00:00:00.000", actual); | ||
} | ||
|
||
@Test | ||
public void testToDateTime() throws Exception { | ||
var actual = Helper.toDateTime("2021-01-01T00:00:00.000"); | ||
|
||
Assertions.assertEquals(2021, actual.getYear()); | ||
Assertions.assertEquals(1, actual.getMonthValue()); | ||
Assertions.assertEquals(1, actual.getDayOfMonth()); | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
.../CommonUtils/Dhis2CucumberTestTool/src/test/java/org/rtsl/dhis2/cucumber/PeriodTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package org.rtsl.dhis2.cucumber; | ||
|
||
import java.time.LocalDate; | ||
import java.time.temporal.ChronoUnit; | ||
import java.time.temporal.TemporalAdjuster; | ||
import java.time.temporal.TemporalAdjusters; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class PeriodTests { | ||
@Test | ||
public void testMonthsAgo() throws Exception { | ||
assertMonthsBetween("3_MonthsAgo", -3); | ||
} | ||
|
||
@Test | ||
public void testThisMonth() throws Exception { | ||
assertMonthsBetween("thisMonth", 0); | ||
} | ||
|
||
@Test | ||
public void testQuartersAgo() throws Exception { | ||
LocalDate today = LocalDate.now(); | ||
LocalDate pointInTime = Period.parseRelativeDate("2_QuartersAgo"); | ||
long diff = ChronoUnit.MONTHS.between(pointInTime, today); | ||
Assertions.assertTrue(diff >= 6); // Closer boundary | ||
Assertions.assertTrue(diff <= 9); // Farther boundary | ||
} | ||
|
||
@Test | ||
public void testThisQuarter() throws Exception { | ||
LocalDate today = LocalDate.now(); | ||
LocalDate pointInTime = Period.parseRelativeDate("thisQuarter"); | ||
long diff = ChronoUnit.MONTHS.between(pointInTime, today); | ||
Assertions.assertTrue(diff >= 0); // Closer boundary | ||
Assertions.assertTrue(diff <= 3); // Farther boundary | ||
} | ||
|
||
@Test | ||
public void testBeginningOfMonth() throws Exception { | ||
LocalDate thisMonth = Period.parseRelativeDate("thisMonth"); | ||
LocalDate firstDayOfMonth = thisMonth.with(TemporalAdjusters.firstDayOfMonth()); | ||
LocalDate pointInTime = Period.parseRelativeDate("BeginningOfMonth"); | ||
Assertions.assertEquals(firstDayOfMonth, pointInTime); | ||
} | ||
|
||
@Test | ||
public void testEndOfMonth() throws Exception { | ||
LocalDate thisMonth = Period.parseRelativeDate("thisMonth"); | ||
LocalDate firstDayOfMonth = thisMonth.with(TemporalAdjusters.lastDayOfMonth()); | ||
LocalDate pointInTime = Period.parseRelativeDate("EndOfMonth"); | ||
Assertions.assertEquals(firstDayOfMonth, pointInTime); | ||
} | ||
|
||
@Test | ||
public void testDaysAgo() throws Exception { | ||
assertDaysBetween("4_DaysAgo", -4); | ||
} | ||
|
||
@Test | ||
public void testPlusDays() throws Exception { | ||
LocalDate thisMonth = Period.parseRelativeDate("thisMonth"); | ||
assertDaysBetweenFrom(thisMonth, "thisMonth_Plus_1_Day", 1); | ||
} | ||
|
||
@Test | ||
public void testPlusMonths() throws Exception { | ||
LocalDate thisMonth = Period.parseRelativeDate("thisMonth"); | ||
assertMonthsBetweenFrom(thisMonth, "thisMonth_Plus_1_Month", 1); | ||
} | ||
|
||
@Test | ||
public void testMinusDays() throws Exception { | ||
LocalDate thisMonth = Period.parseRelativeDate("thisMonth"); | ||
assertDaysBetweenFrom(thisMonth, "thisMonth_Minus_1_Day", -1); | ||
} | ||
|
||
@Test | ||
public void testMinusMonths() throws Exception { | ||
LocalDate thisMonth = Period.parseRelativeDate("thisMonth"); | ||
assertMonthsBetweenFrom(thisMonth, "thisMonth_Minus_1_Month", -1); | ||
} | ||
|
||
private void assertMonthsBetween(String relativeDate, long expectedMonths) { | ||
assertTimeBetween(relativeDate, expectedMonths, ChronoUnit.MONTHS); | ||
} | ||
|
||
private void assertDaysBetween(String relativeDate, long expectedDays) { | ||
assertTimeBetween(relativeDate, expectedDays, ChronoUnit.DAYS); | ||
} | ||
|
||
private void assertMonthsBetweenFrom(LocalDate fixedDate, String relativeDate, long expectedMonths) { | ||
assertTimeBetweenFrom(fixedDate, relativeDate, expectedMonths, ChronoUnit.MONTHS); | ||
} | ||
|
||
private void assertDaysBetweenFrom(LocalDate fixedDate, String relativeDate, long expectedDays) { | ||
assertTimeBetweenFrom(fixedDate, relativeDate, expectedDays, ChronoUnit.DAYS); | ||
} | ||
|
||
private void assertTimeBetween(String relativeDate, long expectedMonths, ChronoUnit timeUnit) { | ||
LocalDate today = LocalDate.now(); | ||
assertTimeBetweenFrom(today, relativeDate, expectedMonths, timeUnit); | ||
} | ||
|
||
private void assertTimeBetweenFrom(LocalDate fixedDate, String relativeDate, long expectedMonths, ChronoUnit timeUnit) { | ||
LocalDate pointInTime = Period.parseRelativeDate(relativeDate); | ||
long diff = timeUnit.between(fixedDate, pointInTime); | ||
Assertions.assertEquals(expectedMonths, diff); | ||
} | ||
} |