Skip to content

Commit

Permalink
DST-16098 Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmccormackbconline committed Aug 21, 2024
1 parent 2843043 commit 396895d
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 55 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<String, String> attributes) throws JsonProcessingException;
void insertDomainEvent(HmppsDomainEventType eventType, Map<String, String> attributes);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,5 +19,5 @@ public interface UserEntryService
Set<GroupEntry> getUserGroups(String username);
Map<String, UserEntry> export();
void save(UserEntry user);
void save(String username, UserEntry user) throws JsonProcessingException;
void save(String username, UserEntry user);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,7 +41,8 @@ public DomainEventServiceImpl(
}

@Override
public void insertDomainEvent(HmppsDomainEventType eventType, Map<String, String> additionalInformation) throws JsonProcessingException
@SneakyThrows
public void insertDomainEvent(HmppsDomainEventType eventType, Map<String, String> 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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +51,9 @@ public class UserControllerUpdateTest
@Autowired
private StaffRepository staffRepository;

@Autowired
private DomainEventRepository domainEventRepository;

private MockMvc mvc;

@Before
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 396895d

Please sign in to comment.