Score { public boolean isDetractor() { if (surveyType != null & scoreRules.containsKey(surveyType)){ return score >= scoreRules.get(surveyType).get(surveyTypeScale).get("min") && score <= scoreRules.get(surveyType).get(surveyTypeScale).get("negative_type_max"); } else { return score >= scoreRules.get("NPS").get(surveyTypeScale).get("min") && score <= scoreRules.get("NPS").get(surveyTypeScale).get("negative_type_max"); } } Score(int score, String surveyType, int surveyTypeScale); boolean isDetractor(); boolean isPassive(); boolean isPromoter(); int maximumScore(); int minimumScore();  }
@Test public void whenNotDetractorAndScaleCES_itReturnsFalse() throws Exception { Score score = new Score(0, "CES", 0); Score score2 = new Score(4, "CES", 0); Score score3 = new Score(0, "CES", 1); Score score4 = new Score(4, "CES", 1); assertThat(score.isDetractor()).isFalse(); assertThat(score2.isDetractor()).isFalse(); assertThat(score3.isDetractor()).isFalse(); assertThat(score4.isDetractor()).isFalse(); }
@Test public void whenDetractorAndScaleCSAT_itReturnsTrue() throws Exception { Score score = new Score(1, "CSAT", 0); Score score2 = new Score(2, "CSAT", 0); Score score3= new Score(1, "CSAT", 1); Score score4 = new Score(6, "CSAT", 1); assertThat(score.isDetractor()).isTrue(); assertThat(score2.isDetractor()).isTrue(); assertThat(score3.isDetractor()).isTrue(); assertThat(score4.isDetractor()).isTrue(); }
@Test public void whenNotDetractorAndScaleCSAT_itReturnsFalse() throws Exception { Score score = new Score(0, "CSAT", 0); Score score2 = new Score(3, "CSAT", 0); Score score3 = new Score(0, "CSAT", 1); Score score4 = new Score(7, "CSAT", 1); assertThat(score.isDetractor()).isFalse(); assertThat(score2.isDetractor()).isFalse(); assertThat(score3.isDetractor()).isFalse(); assertThat(score4.isDetractor()).isFalse(); }
@Test public void whenDetractorAndScaleNPS_itReturnsTrue() throws Exception { Score score = new Score(0, "NPS", 0); Score score2 = new Score(6, "NPS", 0); Score score3 = new Score(6, "NPS", 1); Score score4 = new Score(0, "NPS", -1); assertThat(score.isDetractor()).isTrue(); assertThat(score2.isDetractor()).isTrue(); assertThat(score3.isDetractor()).isTrue(); assertThat(score4.isDetractor()).isTrue(); }
@Test public void whenNotDetractorAndScaleNPS_itReturnsFalse() throws Exception { Score score = new Score(-1, "NPS",0); Score score2 = new Score(7, "NPS",0); Score score3 = new Score(-1, "NPS",1); Score score4 = new Score(7, "NPS",1); assertThat(score.isDetractor()).isFalse(); assertThat(score2.isDetractor()).isFalse(); assertThat(score3.isDetractor()).isFalse(); assertThat(score4.isDetractor()).isFalse(); }
@Test public void whenDetractorAndScaleCES_itReturnsTrue() throws Exception { Score score = new Score(1, "CES", 0); Score score2 = new Score(3, "CES", 0); Score score3 = new Score(1, "CES", 1); Score score4 = new Score(3, "CES", 1); assertThat(score.isDetractor()).isTrue(); assertThat(score2.isDetractor()).isTrue(); assertThat(score3.isDetractor()).isTrue(); assertThat(score4.isDetractor()).isTrue(); }