summaryrefslogtreecommitdiff
path: root/src/test/java/com/p4square/grow/ccb
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2017-10-15 19:00:56 -0700
committerJesse Morgan <jesse@jesterpm.net>2017-10-15 19:00:56 -0700
commitb14ec9a9282cb49951b790ce1b48b1a078616926 (patch)
treedeada14d4a407de18812d0e72c32136a2de2caa5 /src/test/java/com/p4square/grow/ccb
parent79b8aacbb7b347bba9d14b1332666e7263a3a058 (diff)
Refactor Chapter Ordering Logic20171015
The bug impacting the CCB integration was due to the "Introduction" chapter having a higher "score" than every other chapter. It was a mistake to use Score to compared chapter progress, particularly since there are more chapters than scores. This change gathers the chapter ordering logic, which was scattered throughout the code into a new Chapters enum. Playlist and Chapter now use Chapters as a key, instead of loose strings. Same for the ProgressReporter interface.
Diffstat (limited to 'src/test/java/com/p4square/grow/ccb')
-rw-r--r--src/test/java/com/p4square/grow/ccb/CCBProgressReporterTest.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/test/java/com/p4square/grow/ccb/CCBProgressReporterTest.java b/src/test/java/com/p4square/grow/ccb/CCBProgressReporterTest.java
index 63a973a..7a2688c 100644
--- a/src/test/java/com/p4square/grow/ccb/CCBProgressReporterTest.java
+++ b/src/test/java/com/p4square/grow/ccb/CCBProgressReporterTest.java
@@ -2,6 +2,7 @@ package com.p4square.grow.ccb;
import com.p4square.ccbapi.CCBAPI;
import com.p4square.ccbapi.model.*;
+import com.p4square.grow.model.Chapters;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.junit.Before;
@@ -65,7 +66,7 @@ public class CCBProgressReporterTest {
.andReturn(growLevelDate).anyTimes();
EasyMock.expect(cache.getIndividualPulldownByLabel(GROW_LEVEL))
.andReturn(growLevelPulldown).anyTimes();
- EasyMock.expect(cache.getPulldownItemByName(LookupTableType.UDF_IND_PULLDOWN_1, "Believer"))
+ EasyMock.expect(cache.getPulldownItemByName(LookupTableType.UDF_IND_PULLDOWN_1, "believer"))
.andReturn(believer).anyTimes();
// Setup the Grow Assessment field.
@@ -81,7 +82,7 @@ public class CCBProgressReporterTest {
.andReturn(growAssessmentDate).anyTimes();
EasyMock.expect(cache.getIndividualPulldownByLabel(ASSESSMENT_LEVEL))
.andReturn(growAssessmentPulldown).anyTimes();
- EasyMock.expect(cache.getPulldownItemByName(LookupTableType.UDF_IND_PULLDOWN_2, "Believer"))
+ EasyMock.expect(cache.getPulldownItemByName(LookupTableType.UDF_IND_PULLDOWN_2, "believer"))
.andReturn(believer).anyTimes();
}
@@ -115,7 +116,7 @@ public class CCBProgressReporterTest {
replay();
// Test reporter
- reporter.reportChapterComplete(user, "Believer", date);
+ reporter.reportChapterComplete(user, Chapters.BELIEVER, date);
// Assert that the profile was updated.
verify();
@@ -138,7 +139,7 @@ public class CCBProgressReporterTest {
replay();
// Test reporter
- reporter.reportChapterComplete(user, "Believer", date);
+ reporter.reportChapterComplete(user, Chapters.BELIEVER, date);
// Assert that the profile was updated.
verify();
@@ -157,7 +158,7 @@ public class CCBProgressReporterTest {
replay();
// Test reporter
- reporter.reportChapterComplete(user, "Believer", date);
+ reporter.reportChapterComplete(user, Chapters.BELIEVER, date);
// Assert that the profile was updated.
verify();
@@ -173,17 +174,21 @@ public class CCBProgressReporterTest {
replay();
// Test reporter
- reporter.reportChapterComplete(user, "Believer", date);
+ reporter.reportChapterComplete(user, Chapters.BELIEVER, date);
// Assert that the profile was updated.
verify();
}
+ /**
+ * Verify that the date is updated even if the level can't be found in the pulldown menu.
+ * @throws Exception
+ */
@Test
public void testReportChapterCompleteNoSuchValue() throws Exception {
// Setup mocks
setupCacheMocks();
- EasyMock.expect(cache.getPulldownItemByName(LookupTableType.UDF_IND_PULLDOWN_1, "Foo"))
+ EasyMock.expect(cache.getPulldownItemByName(LookupTableType.UDF_IND_PULLDOWN_1, "seeker"))
.andReturn(null).anyTimes();
Capture<UpdateIndividualProfileRequest> reqCapture = EasyMock.newCapture();
EasyMock.expect(api.updateIndividualProfile(EasyMock.capture(reqCapture)))
@@ -191,7 +196,7 @@ public class CCBProgressReporterTest {
replay();
// Test reporter
- reporter.reportChapterComplete(user, "Foo", date);
+ reporter.reportChapterComplete(user, Chapters.SEEKER, date);
// Assert that the profile was updated.
verify();