@@ -0,0 +1,2468 @@
+package org.datacite.mds.service.impl;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport org.datacite.mds.domain.Allocator;%0Aimport org.datacite.mds.domain.AllocatorOrDatacentre;%0Aimport org.datacite.mds.util.DomainUtils;%0Aimport org.easymock.EasyMock;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.powermock.api.easymock.PowerMock;%0Aimport org.powermock.core.classloader.annotations.PowerMockIgnore;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0Aimport org.springframework.security.core.userdetails.UserDetails;%0Aimport org.springframework.security.core.userdetails.UserDetailsService;%0Aimport org.springframework.security.core.userdetails.UsernameNotFoundException;%0A%0A@RunWith(PowerMockRunner.class)%0A@PowerMockIgnore( %7B %22javax.*%22, %22org.apache.log4j.*%22 %7D)%0A@PrepareForTest( %7B DomainUtils.class %7D)%0Apublic class UserDetailsServiceImplTest %7B%0A    %0A    UserDetailsService userDetailsService  = new UserDetailsServiceImpl();%0A%0A    Allocator user;%0A%0A    @Before%0A    public void init() %7B%0A        user = new Allocator();%0A        user.setSymbol(%22DUMMY%22);%0A        user.setPassword(%22password%22);%0A        user.setRoleName(%22MY_ROLE%22);%0A        user.setIsActive(true);%0A        PowerMock.mockStatic(DomainUtils.class);%0A    %7D%0A    %0A    @After%0A    public void after() %7B%0A        PowerMock.verifyAll();%0A    %7D%0A%0A    @Test%0A    public void testExistingUser() %7B%0A        mockFindAllocatorOrDatacentre(user);%0A        UserDetails userDetails = userDetailsService.loadUserByUsername(user.getSymbol());%0A        assertEquals(user.getSymbol(), userDetails.getUsername());%0A        assertEquals(user.getPassword(), userDetails.getPassword());%0A    %7D%0A%0A    @Test(expected=UsernameNotFoundException.class)%0A    public void testNonExistingUser() %7B%0A        mockFindAllocatorOrDatacentre(null);%0A        userDetailsService.loadUserByUsername(user.getSymbol());%0A    %7D%0A    %0A    @Test%0A    public void testUserWithNullPassword() %7B%0A        user.setPassword(null);%0A        mockFindAllocatorOrDatacentre(user);%0A        UserDetails userDetails = userDetailsService.loadUserByUsername(user.getSymbol());%0A        assertNull(userDetails);%0A    %7D%0A    %0A    private void mockFindAllocatorOrDatacentre(AllocatorOrDatacentre mockReturn) %7B%0A        EasyMock.expect(DomainUtils.findAllocatorOrDatacentreBySymbol(user.getSymbol())).andReturn(mockReturn);%0A        PowerMock.replay(DomainUtils.class);%0A    %7D%0A%7D%0A

add UserDetailsServiceImplTest