Skip to content

Commit

Permalink
Tester bugfix for xml marshalling
Browse files Browse the repository at this point in the history
#deploy-tps-messaging-service
  • Loading branch information
stigus committed Jan 16, 2024
1 parent 62429f0 commit acb9da6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -17,6 +18,7 @@
import no.nav.tps.ctg.m201.domain.TpsServiceRutineType;
import org.springframework.stereotype.Service;

import javax.xml.namespace.QName;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -50,17 +52,6 @@ public IdentService(ServicerutineConsumer servicerutineConsumer,
this.objectMapper = objectMapper;
}

@SneakyThrows
public static String marshallToXML(JAXBContext requestContext, TpsPersonData endringsmelding) {

var marshaller = requestContext.createMarshaller();

var writer = new StringWriter();
marshaller.marshal(endringsmelding, writer);

return writer.toString();
}

public List<TpsIdentStatusDTO> getIdenter(List<String> identer, List<String> miljoer, Boolean includeProd) {

if (identer.size() > MAX_LIMIT) {
Expand Down Expand Up @@ -89,6 +80,18 @@ public List<TpsIdentStatusDTO> getIdenter(List<String> identer, List<String> mil
.toList();
}

@SneakyThrows
public static String marshallToXML(JAXBContext requestContext, TpsPersonData endringsmelding) {

var marshaller = requestContext.createMarshaller();

var writer = new StringWriter();
JAXBElement<TpsPersonData> element = new JAXBElement<>(new QName("", "tpsPersonData"), TpsPersonData.class, endringsmelding);
marshaller.marshal(element, writer);

return writer.toString();
}

private boolean exists(String ident, TpsServicerutineM201Response response) {

return nonNull(response.getTpsSvar()) &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package no.nav.testnav.apps.tpsmessagingservice.service;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import lombok.extern.slf4j.Slf4j;
import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MappingContext;
Expand All @@ -12,8 +14,6 @@
import no.nav.testnav.libs.data.tpsmessagingservice.v1.SpraakDTO;
import org.springframework.stereotype.Service;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down

0 comments on commit acb9da6

Please sign in to comment.