Skip to content

Commit

Permalink
K1J-399: CertificateStatusUpdateForCare should set number of question…
Browse files Browse the repository at this point in the history
…s for certificates from CS (#1127)

Co-authored-by: Christoffer Sigerhed <[email protected]>
  • Loading branch information
mikaelaromild1 and Christoffer Sigerhed authored Oct 10, 2024
1 parent 9bd39b3 commit c2702df
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ public class QuestionCounter {

public ArendeCount calculateArendeCount(List<Question> questions, FrageStallare frageStallare) {
final var totalAmount = (int) questions.stream()
.filter(question -> frageStallare.isKodEqual(question.getAuthor()))
.filter(question -> frageStallare.isNameEqual(question.getAuthor()))
.count();

final var totalNotAnswered = (int) questions.stream()
.filter(question -> frageStallare.isKodEqual(question.getAuthor()))
.filter(question -> frageStallare.isNameEqual(question.getAuthor()))
.filter(question -> Boolean.FALSE.equals(question.isHandled()))
.filter(question -> question.getAnswer() == null)
.count();

final var totalAnswered = (int) questions.stream()
.filter(question -> frageStallare.isKodEqual(question.getAuthor()))
.filter(question -> frageStallare.isNameEqual(question.getAuthor()))
.filter(question -> Boolean.FALSE.equals(question.isHandled()))
.filter(question -> question.getAnswer() != null)
.count();

final var totalHandled = (int) questions.stream()
.filter(question -> frageStallare.isKodEqual(question.getAuthor()))
.filter(question -> frageStallare.isNameEqual(question.getAuthor()))
.filter(Question::isHandled)
.count();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,33 @@

public enum FrageStallare {

FORSAKRINGSKASSAN("FK"),
WEBCERT("WC");
FORSAKRINGSKASSAN("FK", "Försäkringskassan"),
WEBCERT("WC", "Webcert");

private final String kod;
private final String name;

FrageStallare(String kod) {
FrageStallare(String kod, String name) {
this.kod = kod;
this.name = name;
}

public boolean isKodEqual(String kodValue) {
return this.kod.equalsIgnoreCase(kodValue);
}

public boolean isNameEqual(String nameValue) {
return this.name.equalsIgnoreCase(nameValue);
}

public String getKod() {
return this.kod;
}

public String getName() {
return name;
}

public static FrageStallare getByKod(String kodVal) {
for (FrageStallare f : values()) {
if (f.getKod().equals(kodVal)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ArendeCountTests {
@Test
void shallReturnCorrectAmountOfTotal() {
final var question = Question.builder()
.author(FrageStallare.FORSAKRINGSKASSAN.getKod())
.author(FrageStallare.FORSAKRINGSKASSAN.getName())
.isHandled(true)
.build();

Expand All @@ -54,7 +54,7 @@ void shallReturnCorrectAmountOfTotal() {
@Test
void shallReturnCorrectAmountOfNotAnswered() {
final var question = Question.builder()
.author(FrageStallare.FORSAKRINGSKASSAN.getKod())
.author(FrageStallare.FORSAKRINGSKASSAN.getName())
.isHandled(false)
.build();

Expand All @@ -64,7 +64,7 @@ void shallReturnCorrectAmountOfNotAnswered() {
@Test
void shallReturnCorrectAmountOfAnswered() {
final var question = Question.builder()
.author(FrageStallare.FORSAKRINGSKASSAN.getKod())
.author(FrageStallare.FORSAKRINGSKASSAN.getName())
.isHandled(false)
.answer(
Answer.builder().build()
Expand All @@ -78,7 +78,7 @@ void shallReturnCorrectAmountOfAnswered() {
@Test
void shallReturnCorrectAmountOfHandled() {
final var question = Question.builder()
.author(FrageStallare.FORSAKRINGSKASSAN.getKod())
.author(FrageStallare.FORSAKRINGSKASSAN.getName())
.isHandled(true)
.build();

Expand Down

0 comments on commit c2702df

Please sign in to comment.