From b14ec9a9282cb49951b790ce1b48b1a078616926 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 15 Oct 2017 19:00:56 -0700 Subject: Refactor Chapter Ordering Logic 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. --- .../backend/resources/TrainingRecordResourceTest.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/test/java/com/p4square/grow/backend/resources') diff --git a/src/test/java/com/p4square/grow/backend/resources/TrainingRecordResourceTest.java b/src/test/java/com/p4square/grow/backend/resources/TrainingRecordResourceTest.java index db85051..8a052ef 100644 --- a/src/test/java/com/p4square/grow/backend/resources/TrainingRecordResourceTest.java +++ b/src/test/java/com/p4square/grow/backend/resources/TrainingRecordResourceTest.java @@ -7,6 +7,7 @@ package com.p4square.grow.backend.resources; import java.util.Map; import java.util.HashMap; +import com.p4square.grow.model.Chapters; import org.restlet.data.Method; import org.restlet.Request; import org.restlet.Response; @@ -46,13 +47,13 @@ public class TrainingRecordResourceTest extends ResourceTestBase { mResponse = new Response(mRequest); Playlist playlist = new Playlist(); - playlist.add("introduction", "intro-1"); - playlist.add("seeker", "seeker-1"); - playlist.add("believer", "believer-1"); - playlist.add("believer", "believer-2"); - playlist.add("disciple", "disciple-1"); - playlist.add("teacher", "teacher-1"); - playlist.add("leader", "leader-1"); + playlist.add(Chapters.INTRODUCTION, "intro-1"); + playlist.add(Chapters.SEEKER, "seeker-1"); + playlist.add(Chapters.BELIEVER, "believer-1"); + playlist.add(Chapters.BELIEVER, "believer-2"); + playlist.add(Chapters.DISCIPLE, "disciple-1"); + playlist.add(Chapters.TEACHER, "teacher-1"); + playlist.add(Chapters.LEADER, "leader-1"); mApplication.setDefaultPlaylist(playlist); } -- cgit v1.2.3