diff --git a/src/main/java/uk/co/bconline/ndelius/model/notification/DomainEvent.java b/src/main/java/uk/co/bconline/ndelius/model/notification/DomainEvent.java deleted file mode 100644 index 8ad515b3..00000000 --- a/src/main/java/uk/co/bconline/ndelius/model/notification/DomainEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -package uk.co.bconline.ndelius.model.notification; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class DomainEvent -{ - private Long id; - private String messageBody; - private String messageAttributes; - private Long domainEventTypeId; - private LocalDateTime createdDateTime; - private Boolean failedPublishing; -} diff --git a/src/main/java/uk/co/bconline/ndelius/service/DomainEventService.java b/src/main/java/uk/co/bconline/ndelius/service/DomainEventService.java index 7b84543a..c97bbd59 100644 --- a/src/main/java/uk/co/bconline/ndelius/service/DomainEventService.java +++ b/src/main/java/uk/co/bconline/ndelius/service/DomainEventService.java @@ -1,11 +1,10 @@ package uk.co.bconline.ndelius.service; -import com.fasterxml.jackson.core.JsonProcessingException; import uk.co.bconline.ndelius.model.notification.HmppsDomainEventType; import java.util.Map; public interface DomainEventService { - void insertDomainEvent(HmppsDomainEventType eventType, Map attributes) throws JsonProcessingException; + void insertDomainEvent(HmppsDomainEventType eventType, Map attributes); } diff --git a/src/main/java/uk/co/bconline/ndelius/service/UserEntryService.java b/src/main/java/uk/co/bconline/ndelius/service/UserEntryService.java index 972e425d..3abf433c 100644 --- a/src/main/java/uk/co/bconline/ndelius/service/UserEntryService.java +++ b/src/main/java/uk/co/bconline/ndelius/service/UserEntryService.java @@ -1,6 +1,5 @@ package uk.co.bconline.ndelius.service; -import com.fasterxml.jackson.core.JsonProcessingException; import uk.co.bconline.ndelius.model.SearchResult; import uk.co.bconline.ndelius.model.entry.GroupEntry; import uk.co.bconline.ndelius.model.entry.UserEntry; @@ -20,5 +19,5 @@ public interface UserEntryService Set getUserGroups(String username); Map export(); void save(UserEntry user); - void save(String username, UserEntry user) throws JsonProcessingException; + void save(String username, UserEntry user); } diff --git a/src/main/java/uk/co/bconline/ndelius/service/impl/DomainEventServiceImpl.java b/src/main/java/uk/co/bconline/ndelius/service/impl/DomainEventServiceImpl.java index 756790ad..48ad8729 100644 --- a/src/main/java/uk/co/bconline/ndelius/service/impl/DomainEventServiceImpl.java +++ b/src/main/java/uk/co/bconline/ndelius/service/impl/DomainEventServiceImpl.java @@ -1,7 +1,7 @@ package uk.co.bconline.ndelius.service.impl; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import lombok.val; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +41,8 @@ public DomainEventServiceImpl( } @Override - public void insertDomainEvent(HmppsDomainEventType eventType, Map additionalInformation) throws JsonProcessingException + @SneakyThrows + public void insertDomainEvent(HmppsDomainEventType eventType, Map additionalInformation) { val type = referenceDataRepository.findByCodeAndReferenceDataMasterCodeSetName(eventType.getEventType(), DOMAIN_EVENT_TYPE_REF_DATA_CODE_SET) .orElseThrow(() -> new IllegalStateException("Reference data for domain event type " + eventType.getEventType() + " not found")); diff --git a/src/main/java/uk/co/bconline/ndelius/service/impl/UserEntryServiceImpl.java b/src/main/java/uk/co/bconline/ndelius/service/impl/UserEntryServiceImpl.java index d5509b8a..8958d8f9 100644 --- a/src/main/java/uk/co/bconline/ndelius/service/impl/UserEntryServiceImpl.java +++ b/src/main/java/uk/co/bconline/ndelius/service/impl/UserEntryServiceImpl.java @@ -1,6 +1,5 @@ package uk.co.bconline.ndelius.service.impl; -import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.collect.Sets; import lombok.extern.slf4j.Slf4j; import lombok.val; @@ -260,7 +259,7 @@ public void save(UserEntry user) { } @Override - public void save(String existingUsername, UserEntry user) throws JsonProcessingException + public void save(String existingUsername, UserEntry user) { // Keep hold of the new username, if it's different we'll rename it later val newUsername = user.getUsername(); diff --git a/src/main/java/uk/co/bconline/ndelius/transformer/DomainEventTransformer.java b/src/main/java/uk/co/bconline/ndelius/transformer/DomainEventTransformer.java deleted file mode 100644 index b1e4075d..00000000 --- a/src/main/java/uk/co/bconline/ndelius/transformer/DomainEventTransformer.java +++ /dev/null @@ -1,25 +0,0 @@ -package uk.co.bconline.ndelius.transformer; - -import org.springframework.stereotype.Component; -import uk.co.bconline.ndelius.model.entity.DomainEventEntity; -import uk.co.bconline.ndelius.model.notification.DomainEvent; - -import static java.util.Optional.ofNullable; - -@Component -public class DomainEventTransformer -{ - public DomainEventEntity map(DomainEvent domainEvent) - { - return ofNullable(domainEvent) - .map(de -> DomainEventEntity.builder() - .messageBody(de.getMessageBody()) - .messageAttributes(de.getMessageAttributes()) - .domainEventTypeId(de.getDomainEventTypeId()) - .createdDateTime(de.getCreatedDateTime()) - .failedPublishing(de.getFailedPublishing()) - .build()) - .orElse(null); - } - -} diff --git a/src/test/java/uk/co/bconline/ndelius/controller/UserControllerUpdateTest.java b/src/test/java/uk/co/bconline/ndelius/controller/UserControllerUpdateTest.java index 41c2d92b..4165fb4c 100644 --- a/src/test/java/uk/co/bconline/ndelius/controller/UserControllerUpdateTest.java +++ b/src/test/java/uk/co/bconline/ndelius/controller/UserControllerUpdateTest.java @@ -16,6 +16,7 @@ import org.springframework.web.context.WebApplicationContext; import uk.co.bconline.ndelius.model.*; import uk.co.bconline.ndelius.model.entity.StaffEntity; +import uk.co.bconline.ndelius.repository.db.DomainEventRepository; import uk.co.bconline.ndelius.repository.db.StaffRepository; import java.time.LocalDate; @@ -50,6 +51,9 @@ public class UserControllerUpdateTest @Autowired private StaffRepository staffRepository; + @Autowired + private DomainEventRepository domainEventRepository; + private MockMvc mvc; @Before @@ -156,6 +160,7 @@ public void userCanBeRenamed() throws Exception { String username = nextTestUsername(); String token = token(mvc); + int preDomainEventCount = domainEventRepository.findAll().size(); // Given mvc.perform(post("/api/user") @@ -183,6 +188,8 @@ public void userCanBeRenamed() throws Exception .header("Authorization", "Bearer " + token)) .andExpect(status().isOk()) .andExpect(jsonPath("$.username", is(username + "-renamed"))); + + assertEquals(preDomainEventCount + 1, domainEventRepository.findAll().size()); } @Test