@@ -0,0 +1,2697 @@
+/*%0A * DefaultAuthenticationService.java%0A *%0A * Copyright (C) 2018 %5B A Legge Up %5D%0A *%0A * This software may be modified and distributed under the terms%0A * of the MIT license.  See the LICENSE file for details.%0A */%0A%0Apackage com.aleggeup.confagrid.service.impl;%0A%0Aimport org.junit.After;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.Mockito;%0Aimport org.mockito.junit.MockitoJUnitRunner;%0A%0Aimport com.aleggeup.confagrid.model.User;%0Aimport com.aleggeup.confagrid.service.UserService;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class DefaultAuthenticationServiceTest %7B%0A%0A    private static final String VALID_USERNAME = %22user%22;%0A%0A    private static final String VALID_PASSWORD = %22password%22;%0A%0A    private static final String INVALID_PASSWORD = %22invalid_password%22;%0A%0A    @Mock%0A    private UserService mockUserService;%0A%0A    private DefaultAuthenticationService defaultAuthenticationService;%0A%0A    @Before%0A    public void setUp() %7B%0A        defaultAuthenticationService = new DefaultAuthenticationService(mockUserService);%0A    %7D%0A%0A    @After%0A    public void tearDown() %7B%0A        Mockito.verifyNoMoreInteractions(mockUserService);%0A    %7D%0A%0A    @Test%0A    public void testUserPasswordCheck() %7B%0A        final User user = new User();%0A        user.setPassword(VALID_PASSWORD);%0A%0A        Mockito.when(mockUserService.getById(VALID_USERNAME)).thenReturn(user);%0A        Mockito.when(mockUserService.matches(VALID_PASSWORD, VALID_PASSWORD)).thenReturn(true);%0A%0A        Assert.assertTrue(defaultAuthenticationService.userPasswordCheck(VALID_USERNAME, VALID_PASSWORD));%0A%0A        Mockito.verify(mockUserService).getById(VALID_USERNAME);%0A        Mockito.verify(mockUserService).matches(VALID_PASSWORD, VALID_PASSWORD);%0A    %7D%0A%0A    @Test%0A    public void testUserCheckInvalidPassword() %7B%0A        final User user = new User();%0A        user.setPassword(VALID_PASSWORD);%0A%0A        Mockito.when(mockUserService.getById(VALID_USERNAME)).thenReturn(user);%0A        Mockito.when(mockUserService.matches(INVALID_PASSWORD, VALID_PASSWORD)).thenReturn(false);%0A%0A        Assert.assertFalse(defaultAuthenticationService.userPasswordCheck(VALID_USERNAME, INVALID_PASSWORD));%0A%0A        Mockito.verify(mockUserService).getById(VALID_USERNAME);%0A        Mockito.verify(mockUserService).matches(INVALID_PASSWORD, VALID_PASSWORD);%0A    %7D%0A%0A    @Test%0A    public void testUserCheckUserNotFound() %7B%0A        Mockito.when(mockUserService.getById(VALID_USERNAME)).thenReturn(null);%0A%0A        Assert.assertFalse(defaultAuthenticationService.userPasswordCheck(VALID_USERNAME, VALID_PASSWORD));%0A%0A        Mockito.verify(mockUserService).getById(VALID_USERNAME);%0A    %7D%0A%7D%0A

Add tests for password check in authentication service