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

PR Kommentare bearbeitet

parent 8cd01942
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ interface AntragraumNachrichtMapper {
@Mapping(target = "direction", ignore = true)
@Mapping(target = "id", ignore = true)
@Mapping(target = "messageCode", ignore = true)
@Mapping(target = "messageId", ignore = true)
@Mapping(target = "messageId", source = "rueckfrageId")
@Mapping(target = "postfachAddress", ignore = true)
@Mapping(target = "postfachId", ignore = true)
@Mapping(target = "replyOption", ignore = true)
......
......@@ -103,6 +103,13 @@ class AntragraumGrpcServiceTest {
verify(mapper).toPostfachNachricht(any(GrpcRueckfrageAnswer.class));
}
@Test
void shouldCallAntragraumService() {
antragsraumGrpcService.sendRueckfrageAnswer(GrpcSendRueckfrageAnswerRequestTestFactory.create(), streamObserver);
verify(antragraumService).sendRueckfrageAnswer(anyString(), anyString(), any(PostfachNachricht.class));
}
@Test
void shouldCallOnNext() {
antragsraumGrpcService.sendRueckfrageAnswer(GrpcSendRueckfrageAnswerRequestTestFactory.create(), streamObserver);
......
......@@ -104,6 +104,13 @@ class AntragraumNachrichtMapperTest {
assertThat(result.getMailBody()).isEqualTo(GrpcRueckfrageAnswerTestFactory.TEXT);
}
@Test
void shouldMapMessageId() {
var result = map();
assertThat(result.getMessageId()).isEqualTo(GrpcRueckfrageAnswerTestFactory.RUECKFRAGE_ID);
}
@Test
void shouldMapAttachmentIds() {
var result = map();
......
......@@ -4,6 +4,8 @@ import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.util.UUID;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
......@@ -13,6 +15,8 @@ import org.opensaml.saml.saml2.core.Response;
import de.ozgcloud.nachrichten.NachrichtenManagerProperties;
import de.ozgcloud.nachrichten.postfach.PersistPostfachNachrichtService;
import de.ozgcloud.nachrichten.postfach.PostfachNachricht;
import de.ozgcloud.nachrichten.postfach.PostfachNachrichtTestFactory;
class AntragraumServiceTest {
@Spy
......@@ -84,4 +88,32 @@ class AntragraumServiceTest {
verify(postfachNachrichtService).findRueckfragen(anyString());
}
}
@Nested
class TestSendRueckfragenAnswers {
static final String SAML_TOKEN = "TOKEN";
static final String RUECKFRAGE_ID = UUID.randomUUID().toString();
static final PostfachNachricht NACHRICHT = PostfachNachrichtTestFactory.create();
@Test
void shouldCallVerify() {
service.sendRueckfrageAnswer(SAML_TOKEN, RUECKFRAGE_ID, NACHRICHT);
verify(service).verifyToken(anyString());
}
@Test
void shouldCallVerifier() {
service.findRueckfragen(SAML_TOKEN);
verify(verifier).verify(anyString());
}
@Test
void shouldCallPostfachService() {
service.sendRueckfrageAnswer(SAML_TOKEN, RUECKFRAGE_ID, NACHRICHT);
verify(postfachNachrichtService).persistAnswer(anyString(), any(PostfachNachricht.class));
}
}
}
\ No newline at end of file
package de.ozgcloud.nachrichten.antragraum;
import java.util.List;
import java.util.UUID;
import com.thedeanda.lorem.LoremIpsum;
public class GrpcRueckfrageAnswerTestFactory {
static final String RUECKFRAGE_ID = UUID.randomUUID().toString();
static final String TEXT = LoremIpsum.getInstance().getParagraphs(2, 4);
static final List<String> ATTACHMENT_ID_LIST = List.of(UUID.randomUUID().toString());
static GrpcRueckfrageAnswer create() {
return createBuilder().build();
}
static GrpcRueckfrageAnswer.Builder createBuilder() {
return GrpcRueckfrageAnswer.newBuilder()
.setRueckfrageId(RUECKFRAGE_ID)
.setAnswerText(TEXT)
.addAllAttachmentFileId(ATTACHMENT_ID_LIST);
}
}
package de.ozgcloud.nachrichten.antragraum;
import de.ozgcloud.common.test.TestUtils;
public class GrpcSendRueckfrageAnswerRequestTestFactory {
static final String SAML_TOKEN = TestUtils.loadTextFile("SamlResponse.xml");
static final GrpcRueckfrageAnswer ANSWER = GrpcRueckfrageAnswerTestFactory.create();
static GrpcSendRueckfrageAnswerRequest create() {
return createBuilder().build();
}
static GrpcSendRueckfrageAnswerRequest.Builder createBuilder() {
return GrpcSendRueckfrageAnswerRequest.newBuilder()
.setAnswer(ANSWER)
.setSamlToken(SAML_TOKEN);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment