Skip to content

Commit

Permalink
fix: PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurt Janssen committed Jan 12, 2024
1 parent 96ba837 commit f6b80c3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;

/**
* A request to a "GeefBetalingenHandicap" MAGDA service, which provides information regarding disability payments for an INSZ.
* Adds the following fields to the {@link PersonMagdaRequest}:
* <ul>
* <li>startDate: the start date of the period</li>
* <li>endDate: the end date of the period</li>
* <li>consultDGPH: consult the source DGPH</li>
* <li>consultVSB: consult the source VSB</li>
* <li>consultIrisCare: consult the source IrisCare</li>
* <li>consultNicCin: consult the NicCin</li>
* <li>sources: include the sources to consult</li>
* </ul>
*
* @see <a href="file:resources/templates/GeefBetalingenHandicap/03.00.0000/template.xml">XML template for this request type</a>
Expand All @@ -41,13 +40,7 @@ public static class Builder extends PersonMagdaRequest.Builder<Builder> {
@Getter(AccessLevel.PROTECTED)
private LocalDate endDate;
@Getter(AccessLevel.PROTECTED)
private Boolean consultDGPH;
@Getter(AccessLevel.PROTECTED)
private Boolean consultVSB;
@Getter(AccessLevel.PROTECTED)
private Boolean consultIrisCare;
@Getter(AccessLevel.PROTECTED)
private Boolean consultNicCin;
private Set<HandicapAuthenticSourceType> sources;

public Builder startDate(LocalDate date) {
this.startDate = date;
Expand All @@ -59,23 +52,8 @@ public Builder endDate(LocalDate date) {
return this;
}

public Builder consultDGPH(Boolean value) {
this.consultDGPH = value;
return this;
}

public Builder consultVSB(Boolean value) {
this.consultVSB = value;
return this;
}

public Builder consultIrisCare(Boolean value) {
this.consultIrisCare = value;
return this;
}

public Builder consultNicCin(Boolean value) {
this.consultNicCin = value;
public Builder sources(Set<HandicapAuthenticSourceType> sources) {
this.sources = sources;
return this;
}

Expand All @@ -89,10 +67,7 @@ public GeefBetalingenHandicapRequest build() {
getRegistration(),
getStartDate(),
getEndDate(),
getConsultDGPH(),
getConsultVSB(),
getConsultIrisCare(),
getConsultNicCin()
getSources()
);
}
}
Expand All @@ -106,30 +81,18 @@ public static Builder builder() {
@NotNull
private final LocalDate endDate;
@Nullable
private final Boolean consultDGPH;
@Nullable
private final Boolean consultVSB;
@Nullable
private final Boolean consultIrisCare;
@Nullable
private final Boolean consultNicCin;
private final Set<HandicapAuthenticSourceType> sources;

public GeefBetalingenHandicapRequest(
@NotNull INSZNumber insz,
@NotNull String registration,
@NotNull LocalDate startDate,
@NotNull LocalDate endDate,
@Nullable Boolean consultDGPH,
@Nullable Boolean consultVSB,
@Nullable Boolean consultIrisCare,
@Nullable Boolean consultNicCin) {
@Nullable Set<HandicapAuthenticSourceType> sources) {
super(insz, registration);
this.startDate = startDate;
this.endDate = endDate;
this.consultDGPH = consultDGPH;
this.consultVSB = consultVSB;
this.consultIrisCare = consultIrisCare;
this.consultNicCin = consultNicCin;
this.sources = sources;
}

@Override
Expand All @@ -145,21 +108,27 @@ protected void fillIn(MagdaDocument request, MagdaRegistrationInfo magdaRegistra
request.setValue("//ConsultPaymentsCriteria/ssin", getInsz().getValue());
request.setValue("//ConsultPaymentsCriteria/period/beginDatum", getStartDate().format(dateFormatter));
request.setValue("//ConsultPaymentsCriteria/period/eindDatum", getEndDate().format(dateFormatter));
if(getConsultDGPH() != null) {
request.createTextNode("//ConsultPaymentsCriteria/handicapAuthenticSources", "DGPH", getBooleanTextValue(getConsultDGPH()));
}
if(getConsultVSB() != null) {
request.createTextNode("//ConsultPaymentsCriteria/handicapAuthenticSources", "VSB", getBooleanTextValue(getConsultVSB()));
}
if(getConsultIrisCare() != null) {
request.createTextNode("//ConsultPaymentsCriteria/handicapAuthenticSources", "IrisCare", getBooleanTextValue(getConsultIrisCare()));
Arrays.stream(HandicapAuthenticSourceType.values()).forEach(x -> {
request.createTextNode("//ConsultPaymentsCriteria/handicapAuthenticSources", x.getTypeString(), getSources() != null && getSources().contains(x) ? "true" : "false");
});
}

public enum HandicapAuthenticSourceType {
DGPH("DGPH"),
VSB("VSB"),
IRISCARE("IrisCare"),
NICCIN("NicCin");

private final String typeString;

HandicapAuthenticSourceType(String typeString) {
this.typeString = typeString;
}
if(getConsultNicCin() != null) {
request.createTextNode("//ConsultPaymentsCriteria/handicapAuthenticSources", "NicCin", getBooleanTextValue(getConsultNicCin()));

public String getTypeString() {
return typeString;
}
}

private String getBooleanTextValue(Boolean value) {
return value ? "true" : "false";

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
import java.time.Year;
import java.util.HashSet;
import java.util.Set;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
Expand All @@ -22,24 +24,21 @@ class GeefBetalingenHandicapRequestBuilder {
void buildsRequest() {
var startDate = LocalDate.now().minusYears(1);
var endDate = LocalDate.now();
var sources = new HashSet<GeefBetalingenHandicapRequest.HandicapAuthenticSourceType>();
sources.add(GeefBetalingenHandicapRequest.HandicapAuthenticSourceType.DGPH);
sources.add(GeefBetalingenHandicapRequest.HandicapAuthenticSourceType.VSB);

var request = GeefBetalingenHandicapRequest.builder()
.insz(TestBase.TEST_INSZ)
.startDate(startDate)
.endDate(endDate)
.consultDGPH(true)
.consultVSB(true)
.consultIrisCare(false)
.consultNicCin(false)
.sources(sources)
.build();

assertEquals(INSZNumber.of(TestBase.TEST_INSZ), request.getInsz());
assertEquals(startDate, request.getStartDate());
assertEquals(endDate, request.getEndDate());
assertEquals(true, request.getConsultDGPH());
assertEquals(true, request.getConsultVSB());
assertEquals(false, request.getConsultIrisCare());
assertEquals(false, request.getConsultNicCin());
assertEquals(sources, request.getSources());
}

@Test
Expand Down Expand Up @@ -75,7 +74,7 @@ void throwsException_whenEndDateNull() {
}

@Test
void consultSourcesIsOptional() {
void sourcesIsOptional() {
var startDate = LocalDate.now().minusYears(1);
var endDate = LocalDate.now();

Expand All @@ -85,10 +84,7 @@ void consultSourcesIsOptional() {
.endDate(endDate)
.build();

assertNull(request.getConsultDGPH());
assertNull(request.getConsultVSB());
assertNull(request.getConsultIrisCare());
assertNull(request.getConsultNicCin());
assertNull(request.getSources());
}
}

Expand All @@ -113,15 +109,15 @@ void setup() {

@Test
void setsFields() {
var sources = new HashSet<GeefBetalingenHandicapRequest.HandicapAuthenticSourceType>();
sources.add(GeefBetalingenHandicapRequest.HandicapAuthenticSourceType.DGPH);
sources.add(GeefBetalingenHandicapRequest.HandicapAuthenticSourceType.VSB);

var request = builder
.insz(TestBase.TEST_INSZ)
.startDate(LocalDate.of(2022, 01, 22))
.endDate(LocalDate.of(2023, 05, 16))
.consultDGPH(true)
.consultVSB(true)
.consultIrisCare(false)
.consultNicCin(false)
.sources(sources)
.build()
.toMagdaDocument(info);

Expand All @@ -144,10 +140,10 @@ void doesNotSetSourcesIfNotSpecified(){
.build()
.toMagdaDocument(info);

assertThat(request.getValue("//ConsultPaymentsCriteria/handicapAuthenticSources/DGPH"), is(nullValue()));
assertThat(request.getValue("//ConsultPaymentsCriteria/handicapAuthenticSources/VSB"), is(nullValue()));
assertThat(request.getValue("//ConsultPaymentsCriteria/handicapAuthenticSources/IrisCare"), is(nullValue()));
assertThat(request.getValue("//ConsultPaymentsCriteria/handicapAuthenticSources/NicCin"), is(nullValue()));
assertThat(request.getValue("//ConsultPaymentsCriteria/handicapAuthenticSources/DGPH"), is(equalTo("false")));
assertThat(request.getValue("//ConsultPaymentsCriteria/handicapAuthenticSources/VSB"), is(equalTo("false")));
assertThat(request.getValue("//ConsultPaymentsCriteria/handicapAuthenticSources/IrisCare"), is(equalTo("false")));
assertThat(request.getValue("//ConsultPaymentsCriteria/handicapAuthenticSources/NicCin"), is(equalTo("false")));
}
}
}

0 comments on commit f6b80c3

Please sign in to comment.