diff --git a/effective-pom.xml b/effective-pom.xml
deleted file mode 100644
index f6f3fa4..0000000
--- a/effective-pom.xml
+++ /dev/null
@@ -1,617 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 4.0.0
-
- no.ks.fiks.pom
- fiks-ekstern-super-pom
- 0.0.3
-
- no.ks.fiks
- svarinn2-send-klient
- 1.0.5-SNAPSHOT
- Svarinn2 send-klient
- Klient for å sende meldinger til SvarInn
- https://github.com/ks-no/fiks-svarinn2
-
-
- MIT License
- http://www.opensource.org/licenses/mit-license.php
- repo
-
-
-
-
- KS-fiks
- KS Fiks Utvikling
- fiks-utvikling@ks.no
-
-
-
- scm:git:git@github.com:ks-no/fiks-svarinn2-send-klient.git
- scm:git:git@github.com:ks-no/fiks-svarinn2-send-klient.git
- https://github.com/ks-no/fiks-svarinn2-send-klient
-
-
-
- oss.sonatype.org
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
- oss.sonatype.org
- https://oss.sonatype.org/content/repositories/snapshots/
-
-
-
- false
- -SNAPSHOT
- true
- 1.6
- 3.0.1
- 3.0.1
- 1.6.8
- 1.0.5
-
-
-
- org.projectlombok
- lombok
- 1.16.18
- compile
-
-
- javax.validation
- validation-api
- 2.0.1.Final
- compile
-
-
- io.vavr
- vavr
- 0.10.0
- compile
-
-
- org.eclipse.jetty
- jetty-client
- 9.4.13.v20181111
- compile
-
-
- com.fasterxml.jackson.core
- jackson-core
- 2.9.8
- compile
-
-
- com.fasterxml.jackson.core
- jackson-databind
- 2.9.8
- compile
-
-
- commons-io
- commons-io
- 2.6
- compile
-
-
- no.ks.fiks
- maskinporten-client
- 1.0.8
- compile
-
-
-
-
-
- true
-
-
- false
-
- central
- maven-release
- https://artifactory.fiks.ks.no/artifactory/maven-all/
-
-
-
- false
-
-
- true
-
- snapshots
- maven-snapshots
- https://artifactory.fiks.ks.no/artifactory/maven-all
-
-
-
-
-
- true
-
-
- false
-
- central
- maven-release
- https://artifactory.fiks.ks.no/artifactory/maven-all/
-
-
-
- false
-
-
- true
-
- snapshots
- maven-snapshots
- https://artifactory.fiks.ks.no/artifactory/maven-all
-
-
-
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/src/main/java
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/src/main/scripts
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/src/test/java
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/target/classes
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/target/test-classes
-
-
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/src/main/resources
-
-
-
-
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/src/test/resources
-
-
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/target
- svarinn2-send-klient-1.0.5-SNAPSHOT
-
-
-
- maven-antrun-plugin
- 1.3
-
-
- maven-assembly-plugin
- 2.2-beta-5
-
-
- maven-dependency-plugin
- 2.8
-
-
- maven-release-plugin
- 2.5.3
-
-
- maven-javadoc-plugin
- 3.0.1
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
- maven-source-plugin
- 3.0.1
-
-
- attach-sources
-
- jar
-
-
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.8
- true
-
- oss.sonatype.org
- https://oss.sonatype.org/
- false
-
-
-
- maven-enforcer-plugin
- 3.0.0-M1
-
-
- default-cli
-
-
-
-
-
-
-
-
- validate-snap
-
-
-
- false
-
-
-
-
-
-
-
- org.scijava
- scijava-maven-plugin
- 1.0.0
- compile
-
-
- true
-
-
- org.codehaus.mojo
- flatten-maven-plugin
- 1.0.0
-
-
- flatten
- process-resources
-
- flatten
-
-
-
-
-
-
-
-
-
- true
-
-
-
- flatten.clean
- clean
-
- clean
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
- maven-source-plugin
- 3.0.1
-
-
- attach-sources
-
- jar
-
-
-
-
-
- maven-javadoc-plugin
- 3.0.1
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.8
- true
-
-
- injected-nexus-deploy
- deploy
-
- deploy
-
-
- oss.sonatype.org
- https://oss.sonatype.org/
- false
-
-
-
-
- oss.sonatype.org
- https://oss.sonatype.org/
- false
-
-
-
- org.codehaus.mojo
- flatten-maven-plugin
- 1.0.0
-
-
- flatten
- process-resources
-
- flatten
-
-
-
-
-
-
-
-
-
- true
-
-
-
- flatten.clean
- clean
-
- clean
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
- maven-enforcer-plugin
- 3.0.0-M1
-
-
- default-cli
-
-
-
-
-
-
-
-
- validate-snap
-
-
-
- false
-
-
-
-
-
-
-
- org.scijava
- scijava-maven-plugin
- 1.0.0
- compile
-
-
- true
-
-
- maven-compiler-plugin
- 3.8.0
-
-
- default-compile
- compile
-
- compile
-
-
-
- 1.8
-
-
-
- default-testCompile
- test-compile
-
- testCompile
-
-
-
- 1.8
-
-
-
-
-
- 1.8
-
-
-
- maven-clean-plugin
- 2.5
-
-
- default-clean
- clean
-
- clean
-
-
-
-
-
- maven-resources-plugin
- 2.6
-
-
- default-testResources
- process-test-resources
-
- testResources
-
-
-
- default-resources
- process-resources
-
- resources
-
-
-
-
-
- maven-jar-plugin
- 2.4
-
-
- default-jar
- package
-
- jar
-
-
-
-
-
- maven-surefire-plugin
- 2.12.4
-
-
- default-test
- test
-
- test
-
-
-
-
-
- maven-install-plugin
- 2.4
-
-
- default-install
- install
-
- install
-
-
-
-
-
- maven-deploy-plugin
- 2.7
-
-
- maven-site-plugin
- 3.3
-
-
- default-site
- site
-
- site
-
-
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/target/site
-
-
- org.apache.maven.plugins
- maven-project-info-reports-plugin
-
-
-
-
-
- default-deploy
- site-deploy
-
- deploy
-
-
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/target/site
-
-
- org.apache.maven.plugins
- maven-project-info-reports-plugin
-
-
-
-
-
-
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/target/site
-
-
- org.apache.maven.plugins
- maven-project-info-reports-plugin
-
-
-
-
-
-
-
- /var/lib/jenkins/workspace/fiks-svarinn2-send-klient_master/target/site
-
-
diff --git a/pom.xml b/pom.xml
index be6e99d..12dfef8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,63 +5,110 @@
no.ks.fiks.pom
fiks-ekstern-super-pom
- 0.0.3
+ 0.0.8
no.ks.fiks
- svarinn2-send-klient
+ fiks-io-send-klient
${revision}${changelist}
- Svarinn2 send-klient
- Klient for å sende meldinger til SvarInn
- https://github.com/ks-no/fiks-svarinn2
+ FIKS IO send-klient
+ Klient for å sende meldinger til FIKS IO
+ https://github.com/ks-no/fiks-io
- scm:git:git@github.com:ks-no/fiks-svarinn2-send-klient.git
- scm:git:git@github.com:ks-no/fiks-svarinn2-send-klient.git
- https://github.com/ks-no/fiks-svarinn2-send-klient
+ scm:git:git@github.com:ks-no/fiks-io-send-klient.git
+ scm:git:git@github.com:ks-no/fiks-io-send-klient.git
+ https://github.com/ks-no/fiks-io-send-klient
- 1.0.6
+ 1.1.0
-SNAPSHOT
+ 2.6
+ 2.9.8
+ 9.4.18.v20190429
+ 5.4.2
+ 1.4.2
+ 1.16.18
+ 1.0.11
+ 2.24.5
+ 2.0.1.Final
+ 0.10.0
+ 1.2.3
org.projectlombok
lombok
- 1.16.18
+ ${lombok.version}
javax.validation
validation-api
- 2.0.1.Final
+ ${validation-api.version}
io.vavr
vavr
- 0.10.0
+ ${vavr.version}
org.eclipse.jetty
jetty-client
- 9.4.13.v20181111
+ ${jetty-client.version}
com.fasterxml.jackson.core
jackson-core
- 2.9.8
+ ${jackson.version}
com.fasterxml.jackson.core
jackson-databind
- 2.9.8
+ ${jackson.version}
commons-io
commons-io
- 2.6
+ ${commons-io.version}
no.ks.fiks
maskinporten-client
- 1.0.8
+ ${maskinporten-client.version}
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit-jupiter.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit-jupiter.version}
+ test
+
+
+ org.junit.platform
+ junit-platform-commons
+ ${junit-platform-commons.version}
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback-classic.version}
+ test
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
+
+ org.mockito
+ mockito-junit-jupiter
+ ${mockito.version}
+ test
diff --git a/src/main/java/no/ks/fiks/svarinn2/klient/AuthenticationStrategy.java b/src/main/java/no/ks/fiks/io/klient/AuthenticationStrategy.java
similarity index 79%
rename from src/main/java/no/ks/fiks/svarinn2/klient/AuthenticationStrategy.java
rename to src/main/java/no/ks/fiks/io/klient/AuthenticationStrategy.java
index eada9db..b872753 100644
--- a/src/main/java/no/ks/fiks/svarinn2/klient/AuthenticationStrategy.java
+++ b/src/main/java/no/ks/fiks/io/klient/AuthenticationStrategy.java
@@ -1,4 +1,4 @@
-package no.ks.fiks.svarinn2.klient;
+package no.ks.fiks.io.klient;
import org.eclipse.jetty.client.api.Request;
diff --git a/src/main/java/no/ks/fiks/svarinn2/klient/SvarInnHttpException.java b/src/main/java/no/ks/fiks/io/klient/FiksIOHttpException.java
similarity index 63%
rename from src/main/java/no/ks/fiks/svarinn2/klient/SvarInnHttpException.java
rename to src/main/java/no/ks/fiks/io/klient/FiksIOHttpException.java
index 63afaa6..0be76bf 100644
--- a/src/main/java/no/ks/fiks/svarinn2/klient/SvarInnHttpException.java
+++ b/src/main/java/no/ks/fiks/io/klient/FiksIOHttpException.java
@@ -1,11 +1,11 @@
-package no.ks.fiks.svarinn2.klient;
+package no.ks.fiks.io.klient;
-public class SvarInnHttpException extends RuntimeException {
+public class FiksIOHttpException extends RuntimeException {
private final int status;
private final String response;
- SvarInnHttpException(String message, int status, String response) {
+ FiksIOHttpException(String message, int status, String response) {
super(message);
this.status = status;
this.response = response;
diff --git a/src/main/java/no/ks/fiks/svarinn2/klient/SvarInnUtsendingKlient.java b/src/main/java/no/ks/fiks/io/klient/FiksIOUtsendingKlient.java
similarity index 64%
rename from src/main/java/no/ks/fiks/svarinn2/klient/SvarInnUtsendingKlient.java
rename to src/main/java/no/ks/fiks/io/klient/FiksIOUtsendingKlient.java
index e72a7c7..9619d27 100644
--- a/src/main/java/no/ks/fiks/svarinn2/klient/SvarInnUtsendingKlient.java
+++ b/src/main/java/no/ks/fiks/io/klient/FiksIOUtsendingKlient.java
@@ -1,4 +1,4 @@
-package no.ks.fiks.svarinn2.klient;
+package no.ks.fiks.io.klient;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -6,14 +6,12 @@
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
-import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.util.InputStreamContentProvider;
import org.eclipse.jetty.client.util.InputStreamResponseListener;
import org.eclipse.jetty.client.util.MultiPartContentProvider;
import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpMethod;
import java.io.IOException;
import java.io.InputStream;
@@ -29,34 +27,26 @@
import static org.eclipse.jetty.http.HttpStatus.isServerError;
@Slf4j
-public class SvarInnUtsendingKlient {
+public class FiksIOUtsendingKlient {
- private final HttpClient client = new HttpClient();
- private final String svarInnScheme;
- private final String svarInnHost;
- private final Integer svarInnPort;
+ private final RequestFactory requestFactory;
private final AuthenticationStrategy authenticationStrategy;
private Function requestInterceptor;
- private final ObjectMapper objectMapper = new ObjectMapper();
- private static final String BASE_PATH = "/svarinn2/api/v1/";
+ private final ObjectMapper objectMapper;
- public SvarInnUtsendingKlient(@NonNull String svarInnScheme, @NonNull String svarInnHost, @NonNull Integer svarInnPort, @NonNull AuthenticationStrategy authenticationStrategy, @NonNull Function requestInterceptor) {
- this.svarInnScheme = svarInnScheme;
- this.svarInnHost = svarInnHost;
- this.svarInnPort = svarInnPort;
+ FiksIOUtsendingKlient(@NonNull final RequestFactory requestFactory,
+ @NonNull AuthenticationStrategy authenticationStrategy,
+ @NonNull Function requestInterceptor,
+ @NonNull final ObjectMapper objectMapper) {
+ this.requestFactory = requestFactory;
this.authenticationStrategy = authenticationStrategy;
this.requestInterceptor = requestInterceptor;
-
- try {
- this.client.start();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ this.objectMapper = objectMapper;
}
- public SvarInnUtsendingKlient(@NonNull String svarInnScheme, @NonNull String svarInnHost, @NonNull Integer svarInnPort, @NonNull AuthenticationStrategy authenticationStrategy) {
- this(svarInnScheme, svarInnHost, svarInnPort, authenticationStrategy, r -> r);
+ public static FiksIOUtsendingKlientBuilder builder() {
+ return new FiksIOUtsendingKlientBuilder();
}
public SendtMeldingApiModel send(@NonNull MeldingSpesifikasjonApiModel metadata, @NonNull Option data) {
@@ -68,11 +58,7 @@ public SendtMeldingApiModel send(@NonNull MeldingSpesifikasjonApiModel metadata,
contentProvider.close();
InputStreamResponseListener listener = new InputStreamResponseListener();
- Request request = client.newRequest(svarInnHost, svarInnPort)
- .scheme(svarInnScheme)
- .method(HttpMethod.POST)
- .path(BASE_PATH + "send")
- .content(contentProvider);
+ final Request request = requestFactory.createSendToFiksIORequest(contentProvider);
authenticationStrategy.setAuthenticationHeaders(request);
@@ -83,11 +69,11 @@ public SendtMeldingApiModel send(@NonNull MeldingSpesifikasjonApiModel metadata,
if (isClientError(response.getStatus()) || isServerError(response.getStatus())) {
int status = response.getStatus();
String content = IOUtils.toString(listener.getInputStream(), StandardCharsets.UTF_8);
- throw new SvarInnHttpException(String.format("HTTP-feil under sending av melding (%d): %s", status, content), status, content);
+ throw new FiksIOHttpException(String.format("HTTP-feil under sending av melding (%d): %s", status, content), status, content);
}
return objectMapper.readValue(listener.getInputStream(), SendtMeldingApiModel.class);
} catch (InterruptedException | TimeoutException | ExecutionException | IOException e) {
- throw new RuntimeException("Feil under invokering av svarinn api", e);
+ throw new RuntimeException("Feil under invokering av FIKS IO api", e);
}
}
diff --git a/src/main/java/no/ks/fiks/io/klient/FiksIOUtsendingKlientBuilder.java b/src/main/java/no/ks/fiks/io/klient/FiksIOUtsendingKlientBuilder.java
new file mode 100644
index 0000000..6c434c8
--- /dev/null
+++ b/src/main/java/no/ks/fiks/io/klient/FiksIOUtsendingKlientBuilder.java
@@ -0,0 +1,90 @@
+package no.ks.fiks.io.klient;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.NonNull;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.Request;
+
+import java.util.function.Function;
+
+/**
+ * Builder that must be used to create
+ */
+public class FiksIOUtsendingKlientBuilder {
+
+ private HttpClient httpClient = new HttpClient();
+
+ private String scheme = "https";
+
+ private String hostName;
+
+ private Integer portNumber;
+
+ private AuthenticationStrategy authenticationStrategy;
+
+ private Function requestInterceptor;
+
+ private ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
+
+ public FiksIOUtsendingKlientBuilder withHttpClient(@NonNull final HttpClient httpClient) {
+ this.httpClient = httpClient;
+ return this;
+ }
+
+ public FiksIOUtsendingKlientBuilder withScheme(@NonNull final String scheme) {
+ this.scheme = scheme;
+ return this;
+ }
+
+ public FiksIOUtsendingKlientBuilder withHostName(@NonNull final String hostName) {
+ this.hostName = hostName;
+ return this;
+ }
+
+ public FiksIOUtsendingKlientBuilder withPortNumber(@NonNull final Integer portNumber) {
+ this.portNumber = portNumber;
+ return this;
+ }
+
+ public FiksIOUtsendingKlientBuilder withAuthenticationStrategy(@NonNull final AuthenticationStrategy authenticationStrategy) {
+ this.authenticationStrategy = authenticationStrategy;
+ return this;
+ }
+
+ public FiksIOUtsendingKlientBuilder withRequestInterceptor(Function requestInterceptor) {
+ this.requestInterceptor = requestInterceptor;
+ return this;
+ }
+
+ public FiksIOUtsendingKlientBuilder withObjectMapper(final ObjectMapper objectMapper) {
+ this.objectMapper = objectMapper;
+ return this;
+ }
+
+ public FiksIOUtsendingKlient build() {
+ objectMapper = new ObjectMapper();
+ return new FiksIOUtsendingKlient(
+ createRequestFactory(),
+ authenticationStrategy,
+ getOrCreateRequestInterceptor(),
+ getOrCreateObjectMapper()
+ );
+ }
+
+ private RequestFactory createRequestFactory() {
+ return RequestFactoryImpl.builder()
+ .client(httpClient)
+ .scheme(scheme)
+ .hostName(hostName)
+ .portNumber(portNumber)
+ .build();
+ }
+
+ private Function getOrCreateRequestInterceptor() {
+ return requestInterceptor == null ? request -> request : requestInterceptor;
+ }
+
+ private ObjectMapper getOrCreateObjectMapper() {
+ return objectMapper == null ? new ObjectMapper().findAndRegisterModules() : objectMapper;
+ }
+}
diff --git a/src/main/java/no/ks/fiks/svarinn2/klient/IntegrasjonAuthenticationStrategy.java b/src/main/java/no/ks/fiks/io/klient/IntegrasjonAuthenticationStrategy.java
similarity index 76%
rename from src/main/java/no/ks/fiks/svarinn2/klient/IntegrasjonAuthenticationStrategy.java
rename to src/main/java/no/ks/fiks/io/klient/IntegrasjonAuthenticationStrategy.java
index 6eb6244..d4666f9 100644
--- a/src/main/java/no/ks/fiks/svarinn2/klient/IntegrasjonAuthenticationStrategy.java
+++ b/src/main/java/no/ks/fiks/io/klient/IntegrasjonAuthenticationStrategy.java
@@ -1,4 +1,4 @@
-package no.ks.fiks.svarinn2.klient;
+package no.ks.fiks.io.klient;
import no.ks.fiks.maskinporten.Maskinportenklient;
import org.eclipse.jetty.client.api.Request;
@@ -8,6 +8,10 @@
public class IntegrasjonAuthenticationStrategy implements AuthenticationStrategy {
+ static final String INTEGRASJON_ID = "IntegrasjonId";
+
+ static final String INTEGRASJON_PASSWORD = "IntegrasjonPassord";
+
private final Maskinportenklient maskinportenklient;
private final UUID integrasjonId;
private final String integrasjonPassord;
@@ -21,8 +25,8 @@ public IntegrasjonAuthenticationStrategy(Maskinportenklient maskinportenklient,
@Override
public void setAuthenticationHeaders(Request request) {
request.header(HttpHeader.AUTHORIZATION, "Bearer " + getAccessToken())
- .header("IntegrasjonId", integrasjonId.toString())
- .header("IntegrasjonPassord", integrasjonPassord);
+ .header(INTEGRASJON_ID, integrasjonId.toString())
+ .header(INTEGRASJON_PASSWORD, integrasjonPassord);
}
private String getAccessToken() {
diff --git a/src/main/java/no/ks/fiks/svarinn2/klient/MeldingSpesifikasjonApiModel.java b/src/main/java/no/ks/fiks/io/klient/MeldingSpesifikasjonApiModel.java
similarity index 90%
rename from src/main/java/no/ks/fiks/svarinn2/klient/MeldingSpesifikasjonApiModel.java
rename to src/main/java/no/ks/fiks/io/klient/MeldingSpesifikasjonApiModel.java
index 77cdcd3..3c890be 100644
--- a/src/main/java/no/ks/fiks/svarinn2/klient/MeldingSpesifikasjonApiModel.java
+++ b/src/main/java/no/ks/fiks/io/klient/MeldingSpesifikasjonApiModel.java
@@ -1,4 +1,4 @@
-package no.ks.fiks.svarinn2.klient;
+package no.ks.fiks.io.klient;
import lombok.Builder;
import lombok.Value;
diff --git a/src/main/java/no/ks/fiks/io/klient/RequestFactory.java b/src/main/java/no/ks/fiks/io/klient/RequestFactory.java
new file mode 100644
index 0000000..1cddfde
--- /dev/null
+++ b/src/main/java/no/ks/fiks/io/klient/RequestFactory.java
@@ -0,0 +1,8 @@
+package no.ks.fiks.io.klient;
+
+import org.eclipse.jetty.client.api.ContentProvider;
+import org.eclipse.jetty.client.api.Request;
+
+public interface RequestFactory {
+ Request createSendToFiksIORequest(ContentProvider contentProvider);
+}
diff --git a/src/main/java/no/ks/fiks/io/klient/RequestFactoryImpl.java b/src/main/java/no/ks/fiks/io/klient/RequestFactoryImpl.java
new file mode 100644
index 0000000..87263ba
--- /dev/null
+++ b/src/main/java/no/ks/fiks/io/klient/RequestFactoryImpl.java
@@ -0,0 +1,25 @@
+package no.ks.fiks.io.klient;
+
+import lombok.Builder;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.ContentProvider;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.http.HttpMethod;
+
+@Builder
+public class RequestFactoryImpl implements RequestFactory {
+ static final String BASE_PATH = "/fiks-io/api/v1/";
+ private final HttpClient client;
+ private final String scheme;
+ private final String hostName;
+ private final Integer portNumber;
+
+ @Override
+ public Request createSendToFiksIORequest(ContentProvider contentProvider) {
+ return client.newRequest(hostName, portNumber)
+ .scheme(scheme)
+ .method(HttpMethod.POST)
+ .path(BASE_PATH + "send")
+ .content(contentProvider);
+ }
+}
diff --git a/src/main/java/no/ks/fiks/svarinn2/klient/SendtMeldingApiModel.java b/src/main/java/no/ks/fiks/io/klient/SendtMeldingApiModel.java
similarity index 91%
rename from src/main/java/no/ks/fiks/svarinn2/klient/SendtMeldingApiModel.java
rename to src/main/java/no/ks/fiks/io/klient/SendtMeldingApiModel.java
index 55d640f..a27e4dc 100644
--- a/src/main/java/no/ks/fiks/svarinn2/klient/SendtMeldingApiModel.java
+++ b/src/main/java/no/ks/fiks/io/klient/SendtMeldingApiModel.java
@@ -1,4 +1,4 @@
-package no.ks.fiks.svarinn2.klient;
+package no.ks.fiks.io.klient;
import lombok.Builder;
import lombok.Data;
diff --git a/src/test/java/no/ks/fiks/io/klient/IntegrasjonAuthenticationStrategyTest.java b/src/test/java/no/ks/fiks/io/klient/IntegrasjonAuthenticationStrategyTest.java
new file mode 100644
index 0000000..a094edf
--- /dev/null
+++ b/src/test/java/no/ks/fiks/io/klient/IntegrasjonAuthenticationStrategyTest.java
@@ -0,0 +1,39 @@
+package no.ks.fiks.io.klient;
+
+import no.ks.fiks.maskinporten.Maskinportenklient;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.http.HttpHeader;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class IntegrasjonAuthenticationStrategyTest {
+
+ @Test
+ void setAuthenticationHeaders(@Mock Maskinportenklient maskinportenklient, @Mock Request request) {
+ final UUID integrasjonId = UUID.randomUUID();
+ final String integrasjonPassord = "passord";
+ final String accessToken = "accessToken";
+
+ when(maskinportenklient.getAccessToken(anyString())).thenReturn(accessToken);
+ when(request.header(eq(HttpHeader.AUTHORIZATION), anyString())).thenReturn(request);
+ when(request.header(eq(IntegrasjonAuthenticationStrategy.INTEGRASJON_ID), anyString())).thenReturn(request);
+ when(request.header(eq(IntegrasjonAuthenticationStrategy.INTEGRASJON_PASSWORD), anyString())).thenReturn(request);
+
+ new IntegrasjonAuthenticationStrategy(maskinportenklient, integrasjonId, integrasjonPassord)
+ .setAuthenticationHeaders(request);
+
+ verify(maskinportenklient).getAccessToken(anyString());
+ verify(request).header(eq(HttpHeader.AUTHORIZATION), anyString());
+ verify(request).header(eq(IntegrasjonAuthenticationStrategy.INTEGRASJON_ID), anyString());
+ verify(request).header(eq(IntegrasjonAuthenticationStrategy.INTEGRASJON_PASSWORD), anyString());
+ verifyNoMoreInteractions(maskinportenklient, request);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/no/ks/fiks/io/klient/RequestFactoryTest.java b/src/test/java/no/ks/fiks/io/klient/RequestFactoryTest.java
new file mode 100644
index 0000000..0e4e28b
--- /dev/null
+++ b/src/test/java/no/ks/fiks/io/klient/RequestFactoryTest.java
@@ -0,0 +1,29 @@
+package no.ks.fiks.io.klient;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class RequestFactoryTest {
+
+ @Test
+ void createSendToFiksIORequest() {
+ final String scheme = "http";
+ final String hostName = "localhost";
+ final int portNumber = 9999;
+ final Request sendToFiksIORequest = RequestFactoryImpl.builder()
+ .scheme(scheme)
+ .hostName(hostName)
+ .portNumber(portNumber)
+ .client(new HttpClient())
+ .build()
+ .createSendToFiksIORequest(new StringContentProvider("stuff"));
+ assertEquals(RequestFactoryImpl.BASE_PATH + "send", sendToFiksIORequest.getPath());
+ assertEquals(hostName, sendToFiksIORequest.getHost());
+ assertEquals(scheme, sendToFiksIORequest.getScheme());
+ assertEquals(portNumber, sendToFiksIORequest.getPort());
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 0000000..aff6d79
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,14 @@
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
\ No newline at end of file