Skip to content
Snippets Groups Projects
Commit 216c8f28 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4383 Mapper umbenannt. Fehlende Werte hinzugefügt

parent f026e4ee
No related branches found
No related tags found
No related merge requests found
......@@ -25,17 +25,19 @@ import de.ozgcloud.nachrichten.postfach.antragraum.GrpcRueckfrage;
import org.apache.commons.collections.MapUtils;
import org.mapstruct.Mapper;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.Map;
@Mapper
public interface NachrichtMapper {
public interface AntragraumNachrichtMapper {
String DEFAULT_STATUS = "NEU";
default GrpcRueckfrage toGrpc(PostfachNachricht postfachNachricht) {
return GrpcRueckfrage.newBuilder()
.setId(postfachNachricht.getId())
.setText(postfachNachricht.getMailBody())
.setSendAt(postfachNachricht.getSentAt().toString())
.setSendAt(postfachNachricht.getSentAt().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
.setVorgangName(postfachNachricht.getSubject())
.setVorgangId(postfachNachricht.getVorgangId())
.setStatus(DEFAULT_STATUS)
......
......@@ -33,7 +33,7 @@ import org.apache.commons.lang3.NotImplementedException;
@RequiredArgsConstructor
public class AntragsraumGrpcService extends AntragraumServiceGrpc.AntragraumServiceImplBase {
private final PersistPostfachNachrichtService postfachNachrichtService;
private final NachrichtMapper mapper;
private final AntragraumNachrichtMapper mapper;
private final Saml2Verifier verifier;
private final Saml2Parser parser;
private final Saml2Decrypter decrypter;
......@@ -54,9 +54,11 @@ public class AntragsraumGrpcService extends AntragraumServiceGrpc.AntragraumServ
public void getRueckfrage(GrpcGetRueckfrageRequest request, StreamObserver<GrpcGetRueckfrageResponse> streamObserver) {
verifyToken(request.getSamlToken());
var response = GrpcGetRueckfrageResponse.newBuilder().setRueckfrage(mapper.toGrpc(postfachNachrichtService.getById(request.getRueckfrageId()))).build();
String postfachId = decrypter.decryptPostfachId(parser.parse(request.getSamlToken()));
var rueckfragen = postfachNachrichtService.findRueckfragen(postfachId);
rueckfragen.forEach(rueckfrage -> streamObserver.onNext(GrpcGetRueckfrageResponse.newBuilder().setRueckfrage(mapper.toGrpc(rueckfrage)).build()));
streamObserver.onNext(response);
streamObserver.onCompleted();
}
......
......@@ -28,9 +28,9 @@ import org.mapstruct.factory.Mappers;
import static org.assertj.core.api.Assertions.*;
class NachrichtMapperTest {
class AntragraumNachrichtMapperTest {
NachrichtMapper mapper = Mappers.getMapper(NachrichtMapper.class);
AntragraumNachrichtMapper mapper = Mappers.getMapper(AntragraumNachrichtMapper.class);
@Test
void shouldMapVorgangId() {
......@@ -39,6 +39,13 @@ class NachrichtMapperTest {
assertThat(result.getVorgangId()).isEqualTo(MessageTestFactory.VORGANG_ID);
}
@Test
void shouldMapId() {
var result = map();
assertThat(result.getId()).isEqualTo(PostfachNachrichtTestFactory.ID);
}
@Test
void shouldMapVorgangName() {
var result = map();
......@@ -50,7 +57,7 @@ class NachrichtMapperTest {
void shouldMapStatus() {
var result = map();
assertThat(result.getStatus()).isEqualTo(NachrichtMapper.DEFAULT_STATUS);
assertThat(result.getStatus()).isEqualTo(AntragraumNachrichtMapper.DEFAULT_STATUS);
}
@Test
......
......@@ -45,7 +45,7 @@ class AntragsraumGrpcServiceTest {
@Mock
private PersistPostfachNachrichtService postfachNachrichtService;
@Mock
private NachrichtMapper mapper;
private AntragraumNachrichtMapper mapper;
@Mock
private Saml2Verifier verifier;
@Mock
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment