// Path: src/main/java/com/jeanchampemont/notedown/NoteDownApplication.java
// @Configuration
// @ComponentScan
// @EnableAutoConfiguration
// @EnableScheduling
// public class NoteDownApplication {
// 
//     public static void main(String[] args) {
//         SpringApplication.run(NoteDownApplication.class, args);
//     }
// 
// }
// 
// Path: src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java
// @Service
// public class AuthenticationService {
//     private UserRepository userRepository;
// 
//     private AuthenticationManager authenticationManager;
// 
//     @Autowired
//     public AuthenticationService(UserRepository userRepository, AuthenticationManager authenticationManager) {
//         this.userRepository = userRepository;
//         this.authenticationManager = authenticationManager;
//     }
// 
//     public User getCurrentUser() {
//         String email = SecurityContextHolder.getContext().getAuthentication().getName();
//         return userRepository.findByEmailIgnoreCase(email);
//     }
// 
//     public boolean isAuthenticated() {
//         return (SecurityContextHolder.getContext().getAuthentication() != null);
//     }
// 
//     public void newAuthentication(String email, String password) {
//         Authentication request = new UsernamePasswordAuthenticationToken(email, password);
//         Authentication result = authenticationManager.authenticate(request);
//         SecurityContextHolder.getContext().setAuthentication(result);
//     }
// }
// 
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
//     @Id
//     @GeneratedValue(strategy = GenerationType.TABLE)
//     private long id;
// 
//     @Column(name = "email", unique = true, length = 64)
//     private String email;
// 
//     @Column(name = "password", length = 60)
//     private String password;
// 
//     @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
//     private Set<Note> notes = new HashSet<>();
// 
//     @Column(name = "locale", length = 2)
//     private String locale;
// 
//     @Column(name = "display_name", length = 64)
//     private String displayName;
// 
//     public long getId() {
//         return id;
//     }
// 
//     public void setId(long id) {
//         this.id = id;
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     public Set<Note> getNotes() {
//         return notes;
//     }
// 
//     public void setNotes(Set<Note> notes) {
//         this.notes = notes;
//     }
// 
//     public String getLocale() {
//         return locale;
//     }
// 
//     public void setLocale(String locale) {
//         this.locale = locale;
//     }
// 
//     public String getDisplayName() {
//         return displayName;
//     }
// 
//     public void setDisplayName(String displayName) {
//         this.displayName = displayName;
//     }
// }
// 
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//     User findByEmailIgnoreCase(String email);
// }
// 
// Path: src/main/java/com/jeanchampemont/notedown/utils/exception/OperationNotAllowedException.java
// public class OperationNotAllowedException extends RuntimeException {
// 
// }


import java.util.Optional;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
import com.jeanchampemont.notedown.NoteDownApplication;
import com.jeanchampemont.notedown.security.AuthenticationService;
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import com.jeanchampemont.notedown.utils.exception.OperationNotAllowedException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/*
 * Copyright (C) 2014 NoteDown
 *
 * This file is part of the NoteDown project.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jeanchampemont.notedown.user;





@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = NoteDownApplication.class)
public class UserServiceTest {
    private UserService sut;

    private AuthenticationService authenticationServiceMock;

// Path: src/main/java/com/jeanchampemont/notedown/NoteDownApplication.java
// @Configuration
// @ComponentScan
// @EnableAutoConfiguration
// @EnableScheduling
// public class NoteDownApplication {
// 
//     public static void main(String[] args) {
//         SpringApplication.run(NoteDownApplication.class, args);
//     }
// 
// }
// 
// Path: src/main/java/com/jeanchampemont/notedown/security/AuthenticationService.java
// @Service
// public class AuthenticationService {
//     private UserRepository userRepository;
// 
//     private AuthenticationManager authenticationManager;
// 
//     @Autowired
//     public AuthenticationService(UserRepository userRepository, AuthenticationManager authenticationManager) {
//         this.userRepository = userRepository;
//         this.authenticationManager = authenticationManager;
//     }
// 
//     public User getCurrentUser() {
//         String email = SecurityContextHolder.getContext().getAuthentication().getName();
//         return userRepository.findByEmailIgnoreCase(email);
//     }
// 
//     public boolean isAuthenticated() {
//         return (SecurityContextHolder.getContext().getAuthentication() != null);
//     }
// 
//     public void newAuthentication(String email, String password) {
//         Authentication request = new UsernamePasswordAuthenticationToken(email, password);
//         Authentication result = authenticationManager.authenticate(request);
//         SecurityContextHolder.getContext().setAuthentication(result);
//     }
// }
// 
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/User.java
// @Entity
// @Table(name = "user_account")
// public class User {
//     @Id
//     @GeneratedValue(strategy = GenerationType.TABLE)
//     private long id;
// 
//     @Column(name = "email", unique = true, length = 64)
//     private String email;
// 
//     @Column(name = "password", length = 60)
//     private String password;
// 
//     @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
//     private Set<Note> notes = new HashSet<>();
// 
//     @Column(name = "locale", length = 2)
//     private String locale;
// 
//     @Column(name = "display_name", length = 64)
//     private String displayName;
// 
//     public long getId() {
//         return id;
//     }
// 
//     public void setId(long id) {
//         this.id = id;
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     public Set<Note> getNotes() {
//         return notes;
//     }
// 
//     public void setNotes(Set<Note> notes) {
//         this.notes = notes;
//     }
// 
//     public String getLocale() {
//         return locale;
//     }
// 
//     public void setLocale(String locale) {
//         this.locale = locale;
//     }
// 
//     public String getDisplayName() {
//         return displayName;
//     }
// 
//     public void setDisplayName(String displayName) {
//         this.displayName = displayName;
//     }
// }
// 
// Path: src/main/java/com/jeanchampemont/notedown/user/persistence/repository/UserRepository.java
// public interface UserRepository extends CrudRepository<User, Long> {
//     User findByEmailIgnoreCase(String email);
// }
// 
// Path: src/main/java/com/jeanchampemont/notedown/utils/exception/OperationNotAllowedException.java
// public class OperationNotAllowedException extends RuntimeException {
// 
// }


// Path: src/test/java/com/jeanchampemont/notedown/user/UserServiceTest.java
import java.util.Optional;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
import com.jeanchampemont.notedown.NoteDownApplication;
import com.jeanchampemont.notedown.security.AuthenticationService;
import com.jeanchampemont.notedown.user.persistence.User;
import com.jeanchampemont.notedown.user.persistence.repository.UserRepository;
import com.jeanchampemont.notedown.utils.exception.OperationNotAllowedException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/*
 * Copyright (C) 2014 NoteDown
 *
 * This file is part of the NoteDown project.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jeanchampemont.notedown.user;





@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = NoteDownApplication.class)
public class UserServiceTest {
    private UserService sut;

    private AuthenticationService authenticationServiceMock;

    private UserRepository repoMock;