Skip to content
Snippets Groups Projects
Commit 58ed4cc7 authored by OZGCloud's avatar OZGCloud
Browse files

prj-42 add webclient / implement smartdocument sandbox

parent 0c3210b0
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,11 @@
<groupId>net.devh</groupId>
<artifactId>grpc-client-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
......
package de.ozgcloud.bescheid.dummy;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;
import com.google.common.net.MediaType;
......@@ -11,6 +12,7 @@ import de.ozgcloud.bescheid.BescheidRequest;
import de.ozgcloud.bescheid.vorgang.Vorgang;
@Service
@ConditionalOnMissingBean(BescheidRemoteService.class)
class DummyBescheidRemoteService implements BescheidRemoteService {
private static final String DUMMY_BESCHEID_FILE_NAME = "dummy-bescheid.pdf";
......
package de.ozgcloud.bescheid.smartdocuments;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.ozgcloud.bescheid.Bescheid;
import de.ozgcloud.bescheid.BescheidRemoteService;
import de.ozgcloud.bescheid.BescheidRequest;
import de.ozgcloud.bescheid.vorgang.Vorgang;
import lombok.SneakyThrows;
@Service
class SmartDocumentsBescheidRemoteService implements BescheidRemoteService {
@Autowired
private WebClient webClient;
@Autowired
private ObjectMapper objectMapper;
@SneakyThrows
@Override
public Bescheid create(BescheidRequest request, Vorgang vorgang) {
System.out.println(objectMapper.writeValueAsString(createRequest()));
var fluxy = webClient.post().accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.bodyValue(createRequest())
.retrieve()
.bodyToFlux(Map.class);
System.out.println("received: " + fluxy.blockFirst());
// TODO Auto-generated method stub
return null;
}
private SmartDocumentsRequest createRequest() {
return SmartDocumentsRequest.builder().build();
}
}
package de.ozgcloud.bescheid.smartdocuments;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;
@Configuration
class SmartDocumentsConfiguration {
private static final String ADDR = "https://sandbox.smartdocuments.com/wsxmldeposit/deposit/unattended";
@Bean
WebClient smartDocumentsWebClient() {
return WebClient.builder()
.baseUrl(ADDR)
.defaultHeader("Authorization", "Basic aW50ZWdyYXRpb24tdXNlcjpXSEVtTkpUeTdHNVJ6R3M=")
// .filters(ExcahngeFunctions)
.build();
}
}
package de.ozgcloud.bescheid.smartdocuments;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Builder;
import lombok.Getter;
@Builder
@Getter
@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
class SmartDocumentsRequest {
@Builder.Default
private CustomerData customerData = CustomerData.builder().build();
@Builder.Default
private SmartDocument smartDocument = SmartDocument.builder().build();
@Builder
@Getter
static class CustomerData {
@Builder.Default
private String gender = "Male";
@Builder.Default
private String lastname = "Smith";
}
@Builder
@Getter
@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
static class SmartDocument {
@Builder.Default
@JsonProperty("Selection")
private Selection selection = Selection.builder().build();
@Builder
@Getter
@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
static class Selection {
@Builder.Default
private String templateGroup = "Development";
@Builder.Default
private String template = "integration-test";
}
}
}
......@@ -13,11 +13,11 @@ public class BescheidRequestTestFactory {
static final LocalDate BESCHEID_VOM = LocalDate.parse(BESCHEID_VOM_STRING);
static final boolean GENEHMIGT = true;
static BescheidRequest create() {
public static BescheidRequest create() {
return createBuilder().build();
}
static BescheidRequest.BescheidRequestBuilder createBuilder() {
public static BescheidRequest.BescheidRequestBuilder createBuilder() {
return BescheidRequest.builder()
.vorgangId(VORGANG_ID)
.bescheidVom(BESCHEID_VOM)
......
package de.ozgcloud.bescheid.smartdocuments;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import de.itvsh.kop.common.test.ITCase;
import de.ozgcloud.bescheid.BescheidRequestTestFactory;
import de.ozgcloud.bescheid.vorgang.VorgangTestFactory;
@ITCase
class SmartDocumentsBescheidRemoteServiceITCase {
@Autowired
private SmartDocumentsBescheidRemoteService remoteService;
@Test
void test() {
remoteService.create(BescheidRequestTestFactory.create(), VorgangTestFactory.create());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment