-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds functionality to remove admin reference when deleted (#237)
* Adds functionality to remove admin reference when deleted
- Loading branch information
1 parent
7f217ba
commit d892531
Showing
13 changed files
with
183 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...main/resources/db/migration/V1_97__alter_lastupdatedby_and_createdby_null_constraints.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ALTER TABLE IF EXISTS public.grant_advert | ||
ALTER COLUMN created_by DROP NOT NULL; | ||
|
||
ALTER TABLE IF EXISTS public.grant_advert | ||
ALTER COLUMN last_updated_by DROP NOT NULL; | ||
|
||
ALTER TABLE IF EXISTS public.grant_application | ||
ALTER COLUMN created_by DROP NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
|
||
import java.time.Instant; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
@@ -420,7 +421,8 @@ void updateApplicationForm_GenericApplicationFormException() throws Exception { | |
@Test | ||
void getLastUpdatedEmailHappyPath() throws Exception { | ||
when(userService.getEmailAddressForSub(anyString())).thenReturn("[email protected]"); | ||
when(applicationFormRepository.findById(anyInt())).thenReturn(Optional.of(ApplicationFormEntity.builder().lastUpdateBy(1).build())); | ||
when(applicationFormService.getApplicationById(anyInt())).thenReturn(ApplicationFormEntity.builder() | ||
.lastUpdateBy(1).build()); | ||
when(userService.getGrantAdminById(anyInt())).thenReturn(Optional.of(GrantAdmin.builder().gapUser(GapUser.builder().userSub("sub").build()).build())); | ||
|
||
this.mockMvc.perform(get("/application-forms/1/lastUpdated/email")).andExpect(status().isOk()) | ||
|
@@ -429,15 +431,20 @@ void getLastUpdatedEmailHappyPath() throws Exception { | |
} | ||
|
||
@Test | ||
void getLastUpdatedEmailReturnsNotFoundWhenNoApplicationFound() throws Exception { | ||
when(applicationFormRepository.findById(anyInt())).thenReturn(Optional.empty()); | ||
this.mockMvc.perform(get("/application-forms/1/lastUpdated/email")).andExpect(status().isNotFound()); | ||
void shouldReturnDeletedUserWhenLastUpdatedByIsNullAndLastUpdatedIsValid() throws Exception { | ||
when(userService.getEmailAddressForSub(anyString())).thenReturn("[email protected]"); | ||
when(applicationFormService.getApplicationById(anyInt())).thenReturn(ApplicationFormEntity.builder() | ||
.lastUpdated(Instant.now()).build()); | ||
|
||
this.mockMvc.perform(get("/application-forms/1/lastUpdated/email")).andExpect(status().isOk()) | ||
.andExpect(content().string("Deleted user")); | ||
|
||
} | ||
|
||
@Test | ||
void getLastUpdatedEmailReturnsNotFoundWhenNoGrantAdminFound() throws Exception { | ||
when(applicationFormRepository.findById(anyInt())). | ||
thenReturn(Optional.of(ApplicationFormEntity.builder().lastUpdateBy(1).build())); | ||
when(applicationFormService.getApplicationById(anyInt())).thenReturn(ApplicationFormEntity.builder() | ||
.lastUpdateBy(1).build()); | ||
when(userService.getGrantAdminById(anyInt())).thenReturn(Optional.empty()); | ||
this.mockMvc.perform(get("/application-forms/1/lastUpdated/email")).andExpect(status().isNotFound()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.