Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbucket-pipelines committed Aug 9, 2024
2 parents 8dd7bcd + b1d0720 commit da42d4e
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 37 deletions.
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>magda</artifactId>
<groupId>be.vlaanderen.vip.mock</groupId>
<version>2.39.0</version>
<version>2.40.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion interfaces/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>magda</artifactId>
<groupId>be.vlaanderen.vip.mock</groupId>
<version>2.39.0</version>
<version>2.40.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.List;

/**
* A MagdaConnector-based client which handles both level 2 and level 3 uitzondingen in the response.
* Level 3 uitzondingen are handled in an opinionated manner whereby an exception is thrown if at least one of them is of type "FOUT".
* A MagdaConnector-based client which handles both level 2 and level 3 uitzonderingen in the response.
* Level 3 uitzonderingen are handled in an opinionated manner whereby an exception is thrown if at least one of them is of type "FOUT".
*/
public class ConnectorMagdaClient extends AbstractConnectorMagdaClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import be.vlaanderen.vip.magda.exception.UitzonderingenSectionInResponseException;

/**
* A MagdaConnector-based client which handles level 2 uitzondingen in the response.
* A MagdaConnector-based client which handles level 2 uitzonderingen in the response.
*/
public class LenientConnectorMagdaClient extends AbstractConnectorMagdaClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import java.time.LocalDate;
import java.time.Year;
import java.util.List;
import java.util.Optional;

/**
* Information on a citizen's history of enrollment in education.
*/
public interface EnrollmentHistory {

static EnrollmentHistory ofMagdaDocument(MagdaDocument magdaDocument) throws MagdaClientException {
static Optional<EnrollmentHistory> ofMagdaDocument(MagdaDocument magdaDocument) throws MagdaClientException {
return MagdaResponseEnrollmentHistoryAdapterJaxbImpl.getInstance().adapt(new MagdaResponseWrapper(MagdaResponse.builder()
.document(magdaDocument)
.build()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import be.vlaanderen.vip.magda.client.MagdaClientException;
import be.vlaanderen.vip.magda.client.diensten.GeefHistoriekInschrijvingRequest;

import java.util.Optional;
import java.util.UUID;

/**
Expand All @@ -11,18 +12,18 @@
public interface GiveEnrollmentHistoryService {

/**
* Retrieves education enrollment history information from a GeefHistoriekInschrijvingRequest request.
* Retrieves education enrollment history information, if any, from a GeefHistoriekInschrijvingRequest request.
*
* @see EnrollmentHistory
* @see GeefHistoriekInschrijvingRequest
*/
EnrollmentHistory getEnrollmentHistory(GeefHistoriekInschrijvingRequest request) throws MagdaClientException;
Optional<EnrollmentHistory> getEnrollmentHistory(GeefHistoriekInschrijvingRequest request) throws MagdaClientException;

/**
* Retrieves education enrollment history information from a GeefHistoriekInschrijvingRequest request, with a provided request ID.
* Retrieves education enrollment history information, if any, from a GeefHistoriekInschrijvingRequest request, with a provided request ID.
*
* @see EnrollmentHistory
* @see GeefHistoriekInschrijvingRequest
*/
EnrollmentHistory getEnrollmentHistory(GeefHistoriekInschrijvingRequest request, UUID requestId) throws MagdaClientException;
Optional<EnrollmentHistory> getEnrollmentHistory(GeefHistoriekInschrijvingRequest request, UUID requestId) throws MagdaClientException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import be.vlaanderen.vip.magda.exception.UitzonderingenSectionInResponseException;
import be.vlaanderen.vip.magda.legallogging.model.UitzonderingType;

import java.util.Optional;
import java.util.UUID;

public class MagdaClientGiveEnrollmentHistoryService implements GiveEnrollmentHistoryService {
Expand All @@ -27,7 +28,7 @@ public MagdaClientGiveEnrollmentHistoryService(
}

@Override
public EnrollmentHistory getEnrollmentHistory(GeefHistoriekInschrijvingRequest request) throws MagdaClientException {
public Optional<EnrollmentHistory> getEnrollmentHistory(GeefHistoriekInschrijvingRequest request) throws MagdaClientException {
var responseWrapper = client.send(request);

validateResponse(responseWrapper.getResponse(), request);
Expand All @@ -36,7 +37,7 @@ public EnrollmentHistory getEnrollmentHistory(GeefHistoriekInschrijvingRequest r
}

@Override
public EnrollmentHistory getEnrollmentHistory(GeefHistoriekInschrijvingRequest request, UUID requestId) throws MagdaClientException {
public Optional<EnrollmentHistory> getEnrollmentHistory(GeefHistoriekInschrijvingRequest request, UUID requestId) throws MagdaClientException {
var responseWrapper = client.send(request, requestId);

validateResponse(responseWrapper.getResponse(), request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import be.vlaanderen.vip.magda.client.MagdaClientException;
import be.vlaanderen.vip.magda.client.MagdaResponseWrapper;

import java.util.Optional;

public interface MagdaResponseEnrollmentHistoryAdapter {

EnrollmentHistory adapt(MagdaResponseWrapper wrapper) throws MagdaClientException;
Optional<EnrollmentHistory> adapt(MagdaResponseWrapper wrapper) throws MagdaClientException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import jakarta.xml.bind.JAXBException;
import lombok.SneakyThrows;

import java.util.NoSuchElementException;
import java.util.Optional;

public class MagdaResponseEnrollmentHistoryAdapterJaxbImpl implements MagdaResponseEnrollmentHistoryAdapter {
Expand All @@ -29,16 +28,19 @@ private MagdaResponseEnrollmentHistoryAdapterJaxbImpl() {
}

@Override
public EnrollmentHistory adapt(MagdaResponseWrapper wrapper) throws MagdaClientException {
public Optional<EnrollmentHistory> adapt(MagdaResponseWrapper wrapper) throws MagdaClientException {
try {
var node = Optional.ofNullable(wrapper
.getResponse()
.getDocument()
.xpath("//Inhoud")
.item(0));
return (EnrollmentHistory) context.createUnmarshaller()
.unmarshal(node.orElseThrow());
} catch (NoSuchElementException | JAXBException e) {
if(node.isPresent()) {
return Optional.of((EnrollmentHistory) context.createUnmarshaller().unmarshal(node.get()));
} else {
return Optional.empty();
}
} catch (JAXBException e) {
throw new MagdaClientException("Could not parse magda response", e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion magdaconnector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>magda</artifactId>
<groupId>be.vlaanderen.vip.mock</groupId>
<version>2.39.0</version>
<version>2.40.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion magdamock-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<artifactId>magda</artifactId>
<groupId>be.vlaanderen.vip.mock</groupId>
<version>2.39.0</version>
<version>2.40.0</version>
</parent>
<artifactId>magdamock-starter</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion magdamock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>magda</artifactId>
<groupId>be.vlaanderen.vip.mock</groupId>
<version>2.39.0</version>
<version>2.40.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,33 @@
import be.vlaanderen.vip.magda.client.diensten.GeefHistoriekInschrijvingRequest;
import be.vlaanderen.vip.magda.client.domain.giveenrollmenthistory.EnrollmentHistory;
import be.vlaanderen.vip.mock.magda.client.domain.MagdaMock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.*;

class MagdaResponseGiveEnrollmentHistoryIntegrationTest {

private EnrollmentHistory enrollmentHistory;
@Test
void dataIsBoundToResponseDocument() throws MagdaClientException {
var enrollmentHistory = enrollmentHistory("88611099807");

@BeforeEach
void setup() throws MagdaClientException {
enrollmentHistory = enrollmentHistory("88611099807");
assertTrue(enrollmentHistory.isPresent());
var enrollments = enrollmentHistory.get().enrollments();
assertNotNull(enrollments);
assertEquals(6, enrollments.size());
}

@Test
void dataIsBoundToResponseDocument() {
var enrollments = enrollmentHistory.enrollments();
assertNotNull(enrollments);
assertEquals(6, enrollments.size());
void empty_ifResponseDocumentHasNoContent() throws MagdaClientException {
var enrollmentHistory = enrollmentHistory("00000000097");

assertTrue(enrollmentHistory.isEmpty());
}

private EnrollmentHistory enrollmentHistory(String insz) throws MagdaClientException {
private Optional<EnrollmentHistory> enrollmentHistory(String insz) throws MagdaClientException {
var response = MagdaMock.getInstance().send(GeefHistoriekInschrijvingRequest.builder()
.insz(insz)
.startDate(LocalDate.of(2024, 1, 1))
Expand Down
2 changes: 1 addition & 1 deletion magdaservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>magda</artifactId>
<groupId>be.vlaanderen.vip.mock</groupId>
<version>2.39.0</version>
<version>2.40.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>be.vlaanderen.vip.mock</groupId>
<artifactId>magda</artifactId>
<version>2.39.0</version>
<version>2.40.0</version>
<name>magdaservice</name>
<description>MAGDA diensten Mock voor afnemers</description>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion signing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>magda</artifactId>
<groupId>be.vlaanderen.vip.mock</groupId>
<version>2.39.0</version>
<version>2.40.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion tester/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>magda</artifactId>
<groupId>be.vlaanderen.vip.mock</groupId>
<version>2.39.0</version>
<version>2.40.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit da42d4e

Please sign in to comment.