Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K1J-399: CertificateStatusUpdateForCare should set number of questions for certificates from CS #1127

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading