package se.kth.csc.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import se.kth.csc.persist.AccountStore;

public class AdminControllerTest {

    private AccountStore accountStore;
    private ObjectMapper objectMapper;
}

@@ -88,154 +88,2004 @@
 ort 
-se.kth.csc.persist.AccountStore;%0A%0Apublic class AdminControllerTest %7B%0A%0A    private AccountStore accountStore;%0A    private ObjectMapper objectMapper;
+org.junit.Test;%0Aimport se.kth.csc.auth.Role;%0Aimport se.kth.csc.model.Account;%0Aimport se.kth.csc.persist.AccountStore;%0Aimport org.junit.Before;%0Aimport se.kth.csc.persist.QueueStore;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport java.security.Principal;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class AdminControllerTest %7B%0A%0A    // SUT%0A    private AdminController adminController;%0A    // Dependencies%0A    private AccountStore accountStore;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        accountStore = mock(AccountStore.class);%0A        adminController = new AdminController(accountStore, null, null);%0A    %7D%0A%0A    @Test%0A    public void testMakeUserAdmin() throws Exception %7B%0A        HttpServletRequest request = mock(HttpServletRequest.class);%0A        when(request.isUserInRole(Role.ADMIN.getAuthority())).thenReturn(true);%0A        Principal principal = mock(Principal.class);%0A        when(principal.getName()).thenReturn(%22testuser%22);%0A        Account account = mock(Account.class);%0A        when(accountStore.fetchAccountWithPrincipalName(%22testuser%22)).thenReturn(account);%0A%0A        String result = adminController.makeUserAdmin(%22testuser%22, request);%0A        verify(account, atLeastOnce()).setAdmin(true);%0A        assertEquals(result, %22redirect:/admin/settings%22);%0A    %7D%0A%0A    @Test%0A    public void removeUserAdmin() throws Exception %7B%0A        HttpServletRequest request = mock(HttpServletRequest.class);%0A        when(request.isUserInRole(Role.ADMIN.getAuthority())).thenReturn(true);%0A        Principal principal = mock(Principal.class);%0A        when(principal.getName()).thenReturn(%22testuser%22);%0A        Account account = mock(Account.class);%0A        when(accountStore.fetchAccountWithPrincipalName(%22testuser%22)).thenReturn(account);%0A%0A        String result = adminController.removeUserAdmin(%22testuser%22, request);%0A        verify(account, atLeastOnce()).setAdmin(false);%0A        assertEquals(result, %22redirect:/admin/settings%22);%0A    %7D
 %0A%7D%0A

Add tests for adding admins and removing admins.