Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Legger til støtte for printsinstruksjoner
Browse files Browse the repository at this point in the history
  • Loading branch information
johnksv committed Jul 24, 2020
1 parent 5edd774 commit 00cbd28
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
import no.difi.sdp.client2.domain.ForretningsMeldingType;
import no.difi.sdp.client2.domain.TekniskMottaker;

import java.util.List;

public class FysiskPost extends ForretningsMelding {

private KonvoluttAdresse mottaker;
private Posttype posttype;
private Utskriftsfarge utskriftsfarge;
private Returhaandtering returhaandtering;
private KonvoluttAdresse returadresse;
private List<Printinstruksjon> printinstruksjoner;

public FysiskPost() {
super(ForretningsMeldingType.PRINT);
Expand Down Expand Up @@ -61,6 +64,10 @@ public TekniskMottaker getUtskriftsleverandoer() {
return null;
}

public List<Printinstruksjon> getPrintinstruksjoner() {
return printinstruksjoner;
}

public static FysiskPost.Builder builder() {
return new Builder();
}
Expand Down Expand Up @@ -100,6 +107,11 @@ public Builder retur(Returhaandtering haandtering, KonvoluttAdresse returadresse
return this;
}

public Builder printinstruksjoner(List<Printinstruksjon> printinstruksjoner) {
fysiskPost.printinstruksjoner = printinstruksjoner;
return this;
}

public FysiskPost build() {
if (built) throw new IllegalStateException("Can't build twice");
built = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright (C) Posten Norge AS
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -20,6 +20,8 @@
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

import java.io.IOException;
import java.util.Map;
import java.util.stream.Collectors;

public class FysiskPostSerializer extends StdSerializer<FysiskPost> {
public FysiskPostSerializer() {
Expand All @@ -42,6 +44,13 @@ public void serialize(FysiskPost value, JsonGenerator gen, SerializerProvider pr

gen.writeEndObject();

Map<String, String> printinstruksjoner = value.getPrintinstruksjoner()
.stream()
.collect(Collectors.toMap(Printinstruksjon::getNavn, Printinstruksjon::getVerdi));

gen.writeObjectField("printinstruksjoner", printinstruksjoner);


gen.writeEndObject();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package no.difi.sdp.client2.domain.fysisk_post;

public class Printinstruksjon {
private final String navn;
private final String verdi;

public Printinstruksjon(String navn, String verdi) {
this.navn = navn;
this.verdi = verdi;
}

public String getNavn() {
return navn;
}

public String getVerdi() {
return verdi;
}
}
8 changes: 8 additions & 0 deletions src/test/java/no/difi/sdp/client2/ObjectMother.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import no.difi.sdp.client2.domain.MetadataDokument;
import no.difi.sdp.client2.domain.Mottaker;
import no.difi.sdp.client2.domain.Noekkelpar;
import no.difi.sdp.client2.domain.fysisk_post.Printinstruksjon;
import no.digipost.api.representations.Organisasjonsnummer;
import no.difi.sdp.client2.domain.Sertifikat;
import no.difi.sdp.client2.domain.digital_post.DigitalPost;
Expand All @@ -44,8 +45,11 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;


Expand Down Expand Up @@ -113,11 +117,15 @@ public static FysiskPost fysiskPost() {
, "Oslo"
).build();

List<Printinstruksjon> list = new ArrayList<>();
list.add(new Printinstruksjon("key", "value"));
list.add(new Printinstruksjon("key2", "value2"));
return FysiskPost.builder()
.adresse(konvoluttAdresse)
.retur(Returhaandtering.DIREKTE_RETUR, konvoluttAdresse)
.sendesMed(Posttype.A_PRIORITERT)
.utskrift(Utskriftsfarge.FARGE)
.printinstruksjoner(list)
.build();
}

Expand Down

0 comments on commit 00cbd28

Please sign in to comment.