[AB-294] fixing test

This commit is contained in:
Sheldan
2021-06-21 21:51:12 +02:00
parent 0d25b9c384
commit 942a20700e

View File

@@ -323,7 +323,7 @@ public class MuteServiceBeanTest {
@Test @Test
public void testEndMute() { public void testEndMute() {
setupUnMuteMocks(true); setupUnMuteMocks();
when(mute.getMutedUser()).thenReturn(userBeingMuted); when(mute.getMutedUser()).thenReturn(userBeingMuted);
when(userBeingMuted.getUserReference()).thenReturn(user); when(userBeingMuted.getUserReference()).thenReturn(user);
when(mute.getMutingUser()).thenReturn(userMuting); when(mute.getMutingUser()).thenReturn(userMuting);
@@ -356,12 +356,7 @@ public class MuteServiceBeanTest {
@Test @Test
public void testUnMuteMemberInGuild() { public void testUnMuteMemberInGuild() {
executeUnMuteWithLogTest(true); executeUnMuteWithLogTest();
}
@Test
public void testUnMuteMemberWhoLeftGuild() {
executeUnMuteWithLogTest(false);
} }
@Test @Test
@@ -427,14 +422,14 @@ public class MuteServiceBeanTest {
verify(postTargetService, times(0)).sendEmbedInPostTarget(any(MessageToSend.class), eq(MutingPostTarget.MUTE_LOG), eq(SERVER_ID)); verify(postTargetService, times(0)).sendEmbedInPostTarget(any(MessageToSend.class), eq(MutingPostTarget.MUTE_LOG), eq(SERVER_ID));
} }
private void executeUnMuteWithLogTest(boolean stillInGuild) { private void executeUnMuteWithLogTest() {
when(userBeingMuted.getUserReference()).thenReturn(user); when(userBeingMuted.getUserReference()).thenReturn(user);
when(mute.getMutedUser()).thenReturn(userBeingMuted); when(mute.getMutedUser()).thenReturn(userBeingMuted);
when(mute.getMutingUser()).thenReturn(userMuting); when(mute.getMutingUser()).thenReturn(userMuting);
when(mute.getServer()).thenReturn(server); when(mute.getServer()).thenReturn(server);
when(muteRoleManagementService.retrieveMuteRoleForServer(server)).thenReturn(muteRole); when(muteRoleManagementService.retrieveMuteRoleForServer(server)).thenReturn(muteRole);
when(muteRole.getRole()).thenReturn(aRole); when(muteRole.getRole()).thenReturn(aRole);
setupUnMuteMocks(stillInGuild); setupUnMuteMocks();
when(roleService.removeRoleFromUserFuture(userBeingMuted, aRole)).thenReturn(CompletableFuture.completedFuture(null)); when(roleService.removeRoleFromUserFuture(userBeingMuted, aRole)).thenReturn(CompletableFuture.completedFuture(null));
when(memberService.getMemberInServerAsync(userBeingMuted)).thenReturn(CompletableFuture.completedFuture(memberBeingMuted)); when(memberService.getMemberInServerAsync(userBeingMuted)).thenReturn(CompletableFuture.completedFuture(memberBeingMuted));
when(memberService.getMemberInServerAsync(userMuting)).thenReturn(CompletableFuture.completedFuture(memberMuting)); when(memberService.getMemberInServerAsync(userMuting)).thenReturn(CompletableFuture.completedFuture(memberMuting));
@@ -442,13 +437,12 @@ public class MuteServiceBeanTest {
} }
private void setupUnMuteMocks(boolean stillInGuild) { private void setupUnMuteMocks() {
when(mute.getMuteId()).thenReturn(new ServerSpecificId(SERVER_ID, MUTE_ID)); when(mute.getMuteId()).thenReturn(new ServerSpecificId(SERVER_ID, MUTE_ID));
when(muteManagementService.getAMuteOf(userBeingMuted)).thenReturn(mute); when(muteManagementService.getAMuteOf(userBeingMuted)).thenReturn(mute);
when(muteManagementService.hasActiveMute(userBeingMuted)).thenReturn(true); when(muteManagementService.hasActiveMute(userBeingMuted)).thenReturn(true);
when(muteRoleManagementService.retrieveMuteRoleForServer(server)).thenReturn(muteRole); when(muteRoleManagementService.retrieveMuteRoleForServer(server)).thenReturn(muteRole);
when(guildService.getGuildById(server.getId())).thenReturn(guild); when(guildService.getGuildById(server.getId())).thenReturn(guild);
when(memberService.isUserInGuild(guild, userBeingMuted)).thenReturn(stillInGuild);
} }
private void verifyDirectMute() { private void verifyDirectMute() {