// Path: duke-encounters/src/main/java/de/dominikschadow/dukeencounters/config/DukeEncountersProperties.java
// @ConfigurationProperties(prefix = "duke.encounters")
// @Data
// public class DukeEncountersProperties {
//     /**
//      * The number of encounters to be shown in the latest encounters list.
//      */
//     private int latestAmount;
//     private int passwordStrength;
// }
// 
// Path: duke-encounters/src/main/java/de/dominikschadow/dukeencounters/user/UserService.java
// @Service
// @Slf4j
// @AllArgsConstructor
// public class UserService {
//     private final UserRepository userRepository;
//     private final AuthorityRepository authorityRepository;
//     private final PasswordEncoder passwordEncoder;
// 
//     /**
//      * Creates a new user. This user receives the normal user role, is enabled and has the {@link Level} NEWBIE.
//      *
//      * @param newUser The user to create
//      * @return The created user with all fields filled
//      */
//     @Transactional
//     public DukeEncountersUser createUser(@NotNull final DukeEncountersUser newUser) {
//         log.info("Creating user with username {}", newUser.getEmail());
//         Authority authority = authorityRepository.save(new Authority(newUser.getUsername(), "ROLE_USER"));
// 
//         newUser.setEnabled(true);
//         newUser.setLevel(Level.NEWBIE);
//         newUser.setRegistrationDate(new Date());
//         newUser.setAuthority(authority);
//         newUser.setPassword(hashPassword(newUser.getPassword()));
// 
//         DukeEncountersUser user = userRepository.save(newUser);
// 
//         log.warn(SecurityMarkers.SECURITY_AUDIT, "Created a new user with username {} and id {} with role {}",
//                 user.getUsername(), user.getId(), user.getAuthority().getAuthority());
// 
//         return user;
//     }
// 
//     @Transactional
//     public DukeEncountersUser updateUser(@NotNull final DukeEncountersUser dukeEncountersUser) {
//         return userRepository.save(dukeEncountersUser);
//     }
// 
//     public boolean confirmPassword(@NotNull final String password) {
//         return passwordEncoder.matches(password, getDukeEncountersUser().getPassword());
//     }
// 
//     public DukeEncountersUser findUser(final String username) {
//         return userRepository.findByUsername(username);
//     }
// 
//     public String getUsername() {
//         Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// 
//         String username = authentication.getName();
// 
//         if (authentication instanceof UserDetails) {
//             UserDetails userDetails = (UserDetails) authentication;
// 
//             username = userDetails.getUsername();
//         }
// 
//         return username;
//     }
// 
//     public User getUser() {
//         return new User(getUsername());
//     }
// 
//     public DukeEncountersUser getDukeEncountersUser() {
//         return getDukeEncountersUser(getUsername());
//     }
// 
//     public DukeEncountersUser getDukeEncountersUser(@NotNull final String username) {
//         return userRepository.findByUsername(username);
//     }
// 
//     public String hashPassword(String password) {
//         return passwordEncoder.encode(password);
//     }
// }
// 
// Path: duke-encounters/src/test/java/de/dominikschadow/dukeencounters/TestData.java
// public static Encounter testEncounter(long id) {
//     Encounter testEncounter = new Encounter();
//     testEncounter.setId(id);
// 
//     return testEncounter;
// }
// 
// Path: duke-encounters/src/test/java/de/dominikschadow/dukeencounters/TestData.java
// public static List<Encounter> threeTestEncounters() {
//     List<Encounter> encounters = new ArrayList<>();
//     encounters.add(testEncounter(1));
//     encounters.add(testEncounter(2));
//     encounters.add(testEncounter(3));
// 
//     return encounters;
// }
// 
// Path: duke-encounters/src/test/java/de/dominikschadow/dukeencounters/TestData.java
// public static List<Encounter> twoTestEncounters() {
//     List<Encounter> encounters = new ArrayList<>();
//     encounters.add(testEncounter(1));
//     encounters.add(testEncounter(2));
// 
//     return encounters;
// }


import static de.dominikschadow.dukeencounters.TestData.twoTestEncounters;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import de.dominikschadow.dukeencounters.config.DukeEncountersProperties;
import de.dominikschadow.dukeencounters.user.UserService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.owasp.appsensor.core.DetectionSystem;
import org.owasp.appsensor.core.event.EventManager;
import java.util.List;
import static de.dominikschadow.dukeencounters.TestData.testEncounter;
import static de.dominikschadow.dukeencounters.TestData.threeTestEncounters;
/*
 * Copyright (C) 2017 Dominik Schadow, dominikschadow@gmail.com
 *
 * This file is part of the Application Intrusion Detection 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 de.dominikschadow.dukeencounters.encounter;




/**
 * Tests the [@link EncounterService} class.
 *
 * @author Dominik Schadow
 */
public class EncounterServiceTest {
    @Mock
    private EncounterRepository repository;
// Path: duke-encounters/src/main/java/de/dominikschadow/dukeencounters/config/DukeEncountersProperties.java
// @ConfigurationProperties(prefix = "duke.encounters")
// @Data
// public class DukeEncountersProperties {
//     /**
//      * The number of encounters to be shown in the latest encounters list.
//      */
//     private int latestAmount;
//     private int passwordStrength;
// }
// 
// Path: duke-encounters/src/main/java/de/dominikschadow/dukeencounters/user/UserService.java
// @Service
// @Slf4j
// @AllArgsConstructor
// public class UserService {
//     private final UserRepository userRepository;
//     private final AuthorityRepository authorityRepository;
//     private final PasswordEncoder passwordEncoder;
// 
//     /**
//      * Creates a new user. This user receives the normal user role, is enabled and has the {@link Level} NEWBIE.
//      *
//      * @param newUser The user to create
//      * @return The created user with all fields filled
//      */
//     @Transactional
//     public DukeEncountersUser createUser(@NotNull final DukeEncountersUser newUser) {
//         log.info("Creating user with username {}", newUser.getEmail());
//         Authority authority = authorityRepository.save(new Authority(newUser.getUsername(), "ROLE_USER"));
// 
//         newUser.setEnabled(true);
//         newUser.setLevel(Level.NEWBIE);
//         newUser.setRegistrationDate(new Date());
//         newUser.setAuthority(authority);
//         newUser.setPassword(hashPassword(newUser.getPassword()));
// 
//         DukeEncountersUser user = userRepository.save(newUser);
// 
//         log.warn(SecurityMarkers.SECURITY_AUDIT, "Created a new user with username {} and id {} with role {}",
//                 user.getUsername(), user.getId(), user.getAuthority().getAuthority());
// 
//         return user;
//     }
// 
//     @Transactional
//     public DukeEncountersUser updateUser(@NotNull final DukeEncountersUser dukeEncountersUser) {
//         return userRepository.save(dukeEncountersUser);
//     }
// 
//     public boolean confirmPassword(@NotNull final String password) {
//         return passwordEncoder.matches(password, getDukeEncountersUser().getPassword());
//     }
// 
//     public DukeEncountersUser findUser(final String username) {
//         return userRepository.findByUsername(username);
//     }
// 
//     public String getUsername() {
//         Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// 
//         String username = authentication.getName();
// 
//         if (authentication instanceof UserDetails) {
//             UserDetails userDetails = (UserDetails) authentication;
// 
//             username = userDetails.getUsername();
//         }
// 
//         return username;
//     }
// 
//     public User getUser() {
//         return new User(getUsername());
//     }
// 
//     public DukeEncountersUser getDukeEncountersUser() {
//         return getDukeEncountersUser(getUsername());
//     }
// 
//     public DukeEncountersUser getDukeEncountersUser(@NotNull final String username) {
//         return userRepository.findByUsername(username);
//     }
// 
//     public String hashPassword(String password) {
//         return passwordEncoder.encode(password);
//     }
// }
// 
// Path: duke-encounters/src/test/java/de/dominikschadow/dukeencounters/TestData.java
// public static Encounter testEncounter(long id) {
//     Encounter testEncounter = new Encounter();
//     testEncounter.setId(id);
// 
//     return testEncounter;
// }
// 
// Path: duke-encounters/src/test/java/de/dominikschadow/dukeencounters/TestData.java
// public static List<Encounter> threeTestEncounters() {
//     List<Encounter> encounters = new ArrayList<>();
//     encounters.add(testEncounter(1));
//     encounters.add(testEncounter(2));
//     encounters.add(testEncounter(3));
// 
//     return encounters;
// }
// 
// Path: duke-encounters/src/test/java/de/dominikschadow/dukeencounters/TestData.java
// public static List<Encounter> twoTestEncounters() {
//     List<Encounter> encounters = new ArrayList<>();
//     encounters.add(testEncounter(1));
//     encounters.add(testEncounter(2));
// 
//     return encounters;
// }


// Path: duke-encounters/src/test/java/de/dominikschadow/dukeencounters/encounter/EncounterServiceTest.java
import static de.dominikschadow.dukeencounters.TestData.twoTestEncounters;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import de.dominikschadow.dukeencounters.config.DukeEncountersProperties;
import de.dominikschadow.dukeencounters.user.UserService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.owasp.appsensor.core.DetectionSystem;
import org.owasp.appsensor.core.event.EventManager;
import java.util.List;
import static de.dominikschadow.dukeencounters.TestData.testEncounter;
import static de.dominikschadow.dukeencounters.TestData.threeTestEncounters;

/*
 * Copyright (C) 2017 Dominik Schadow, dominikschadow@gmail.com
 *
 * This file is part of the Application Intrusion Detection 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 de.dominikschadow.dukeencounters.encounter;




/**
 * Tests the [@link EncounterService} class.
 *
 * @author Dominik Schadow
 */
public class EncounterServiceTest {
    @Mock
    private EncounterRepository repository;
    @Mock