Restructured packages to adapter/port architecture
parent
72d70b8a57
commit
7366459279
|
@ -0,0 +1,57 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.nclazz.service.mailrelay.adapter.web.MessageForm;
|
||||
import de.nclazz.service.mailrelay.domain.Message;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("integration")
|
||||
@AutoConfigureMockMvc
|
||||
public class ForwardMessageRestTest {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper mapper;
|
||||
|
||||
private static final LocalDateTime FIXED_TIME = LocalDateTime.of(2019, 4, 25, 13, 12);
|
||||
|
||||
@TestConfiguration
|
||||
static class TestConfig {
|
||||
|
||||
@Bean
|
||||
public Clock clock() {
|
||||
return FakeClock.fixed(FIXED_TIME);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void forwardMessageReturnsForwardedMessageAndIsAlwaysOK() throws Exception {
|
||||
MessageForm form = new MessageForm("my-token", "subject", "message", "sender@company.com");
|
||||
Message message = form.toMessage(FIXED_TIME);
|
||||
|
||||
mockMvc.perform(post("/").contentType(APPLICATION_JSON)
|
||||
.content(mapper.writeValueAsString(form)))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(APPLICATION_JSON))
|
||||
.andExpect(content().json(mapper.writeValueAsString(message)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
spring.main.allow-bean-definition-overriding=true
|
|
@ -1,5 +1,6 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.adapter.web;
|
||||
|
||||
import de.nclazz.service.mailrelay.domain.Message;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,5 +1,7 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.adapter.web;
|
||||
|
||||
import de.nclazz.service.mailrelay.domain.Message;
|
||||
import de.nclazz.service.mailrelay.domain.Relay;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
@ -1,4 +1,4 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
|
@ -1,4 +1,4 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,5 +1,9 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.adapter.web;
|
||||
|
||||
import de.nclazz.service.mailrelay.FakeClock;
|
||||
import de.nclazz.service.mailrelay.domain.Message;
|
||||
import de.nclazz.service.mailrelay.domain.Relay;
|
||||
import de.nclazz.service.mailrelay.domain.RelayAccount;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Clock;
|
|
@ -1,4 +1,4 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.domain;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.domain;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.nclazz.service.mailrelay;
|
||||
package de.nclazz.service.mailrelay.domain;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
Loading…
Reference in New Issue