diff --git a/src/main/java/de/filefighter/rest/configuration/PrepareDataBase.java b/src/main/java/de/filefighter/rest/configuration/PrepareDataBase.java index 9066105f..f56c559d 100644 --- a/src/main/java/de/filefighter/rest/configuration/PrepareDataBase.java +++ b/src/main/java/de/filefighter/rest/configuration/PrepareDataBase.java @@ -88,7 +88,7 @@ CommandLineRunner initDataBaseProd(UserRepository userRepository, FileSystemRepo LOG.info("Preloading default fsStructure: {}.", fileSystemRepository.save(FileSystemEntity .builder() .createdByUserId(0) - .id(0) + .fileSystemId(0) .isFile(false) .path("/") .itemIds(new long[0]) @@ -145,7 +145,7 @@ CommandLineRunner initDataBaseDev(UserRepository userRepository, AccessTokenRepo LOG.info("Preloading default fsItems: {} {}.", fileSystemRepository.save(FileSystemEntity.builder() .createdByUserId(0) - .id(0) + .fileSystemId(0) .isFile(false) .path("/") .itemIds(new long[]{1}) @@ -157,7 +157,7 @@ CommandLineRunner initDataBaseDev(UserRepository userRepository, AccessTokenRepo .build()), fileSystemRepository.save(FileSystemEntity.builder() .createdByUserId(0) - .id(1) + .fileSystemId(1) .isFile(true) .lastUpdated(Instant.now().getEpochSecond()) .name("dummyFile.txt") diff --git a/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/File.java b/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/File.java index 1f9a52b2..d4b5183c 100644 --- a/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/File.java +++ b/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/File.java @@ -7,7 +7,7 @@ public class File extends FileSystemItem{ public File() { } - public File(long id, String name, double size, long createdByUserId, long lastUpdated, FileSystemType type, PermissionSet permissionSet) { - super(id, name, size, createdByUserId, lastUpdated, type, permissionSet); + public File(long fileSystemId, String name, double size, long createdByUserId, long lastUpdated, FileSystemType type, PermissionSet permissionSet) { + super(fileSystemId, name, size, createdByUserId, lastUpdated, type, permissionSet); } } \ No newline at end of file diff --git a/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/FileSystemItem.java b/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/FileSystemItem.java index 56caf84f..43452a08 100644 --- a/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/FileSystemItem.java +++ b/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/FileSystemItem.java @@ -8,7 +8,7 @@ @Getter @Setter public class FileSystemItem { - private long id; + private long fileSystemId; private String name; private double size; private long createdByUserId; //uploadedBy @@ -19,8 +19,8 @@ public class FileSystemItem { protected FileSystemItem() { } - public FileSystemItem(long id, String name, double size, long createdByUserId, long lastUpdated, FileSystemType type, PermissionSet permissionSet) { - this.id = id; + public FileSystemItem(long fileSystemId, String name, double size, long createdByUserId, long lastUpdated, FileSystemType type, PermissionSet permissionSet) { + this.fileSystemId = fileSystemId; this.name = name; this.size = size; this.createdByUserId = createdByUserId; diff --git a/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/Folder.java b/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/Folder.java index 8c31aada..38e9b995 100644 --- a/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/Folder.java +++ b/src/main/java/de/filefighter/rest/domain/filesystem/data/dto/Folder.java @@ -9,8 +9,8 @@ public class Folder extends FileSystemItem { public Folder() { } - public Folder(long id, String name, double size, long createdByUserId, long lastUpdated, FileSystemType type, PermissionSet permissionSet, String path) { - super(id, name, size, createdByUserId, lastUpdated, type, permissionSet); + public Folder(long fileSystemId, String name, double size, long createdByUserId, long lastUpdated, FileSystemType type, PermissionSet permissionSet, String path) { + super(fileSystemId, name, size, createdByUserId, lastUpdated, type, permissionSet); this.path = path; } diff --git a/src/main/java/de/filefighter/rest/domain/filesystem/data/persistance/FileSystemEntity.java b/src/main/java/de/filefighter/rest/domain/filesystem/data/persistance/FileSystemEntity.java index f9f33aa0..bbae88f1 100644 --- a/src/main/java/de/filefighter/rest/domain/filesystem/data/persistance/FileSystemEntity.java +++ b/src/main/java/de/filefighter/rest/domain/filesystem/data/persistance/FileSystemEntity.java @@ -12,7 +12,7 @@ public class FileSystemEntity { @MongoId private String mongoId; - private long id; + private long fileSystemId; private String name; private String path; private long typeId; diff --git a/src/main/java/de/filefighter/rest/domain/filesystem/data/persistance/FileSystemRepository.java b/src/main/java/de/filefighter/rest/domain/filesystem/data/persistance/FileSystemRepository.java index 0848889c..ca6cd2e2 100644 --- a/src/main/java/de/filefighter/rest/domain/filesystem/data/persistance/FileSystemRepository.java +++ b/src/main/java/de/filefighter/rest/domain/filesystem/data/persistance/FileSystemRepository.java @@ -5,5 +5,5 @@ @Service public interface FileSystemRepository extends MongoRepository { - FileSystemEntity findById(long id); + FileSystemEntity findByFileSystemId(long fileSystemId); } diff --git a/src/main/java/de/filefighter/rest/domain/token/business/AccessTokenBusinessService.java b/src/main/java/de/filefighter/rest/domain/token/business/AccessTokenBusinessService.java index 1313fdc2..918a019f 100644 --- a/src/main/java/de/filefighter/rest/domain/token/business/AccessTokenBusinessService.java +++ b/src/main/java/de/filefighter/rest/domain/token/business/AccessTokenBusinessService.java @@ -29,7 +29,7 @@ public AccessTokenBusinessService(AccessTokenRepository accessTokenRepository, A } public AccessToken getValidAccessTokenForUser(User user) { - long userId = user.getId(); + long userId = user.getUserId(); AccessTokenEntity accessTokenEntity = accessTokenRepository.findByUserId(userId); long currentTimeSeconds = Instant.now().getEpochSecond(); diff --git a/src/main/java/de/filefighter/rest/domain/user/business/UserBusinessService.java b/src/main/java/de/filefighter/rest/domain/user/business/UserBusinessService.java index a69bb57f..f2df352a 100644 --- a/src/main/java/de/filefighter/rest/domain/user/business/UserBusinessService.java +++ b/src/main/java/de/filefighter/rest/domain/user/business/UserBusinessService.java @@ -62,9 +62,9 @@ public User getUserById(long userId) { } public RefreshToken getRefreshTokenForUser(User user) { - UserEntity userEntity = userRepository.findByUserIdAndUsername(user.getId(), user.getUsername()); + UserEntity userEntity = userRepository.findByUserIdAndUsername(user.getUserId(), user.getUsername()); if (null == userEntity) - throw new UserNotFoundException(user.getId()); + throw new UserNotFoundException(user.getUserId()); String refreshTokenValue = userEntity.getRefreshToken(); @@ -157,7 +157,7 @@ public void updateUser(long userId, UserRegisterForm userToUpdate, User authenti throw new UserNotUpdatedException("Authenticated User is not allowed."); boolean authenticatedUserIsAdmin = Arrays.stream(authenticatedUser.getGroups()).anyMatch(g -> g == Groups.ADMIN); - if (userId != authenticatedUser.getId() && !authenticatedUserIsAdmin) + if (userId != authenticatedUser.getUserId() && !authenticatedUserIsAdmin) throw new UserNotUpdatedException("Only Admins are allowed to update other users."); UserEntity userEntityToUpdate = userRepository.findByUserId(userId); diff --git a/src/main/java/de/filefighter/rest/domain/user/business/UserDtoService.java b/src/main/java/de/filefighter/rest/domain/user/business/UserDtoService.java index a4e5ecd8..54b2fc17 100644 --- a/src/main/java/de/filefighter/rest/domain/user/business/UserDtoService.java +++ b/src/main/java/de/filefighter/rest/domain/user/business/UserDtoService.java @@ -23,7 +23,7 @@ public UserDtoService(GroupRepository groupRepository, UserRepository userReposi public User createDto(UserEntity entity) { return User .builder() - .id(entity.getUserId()) + .userId(entity.getUserId()) .username(entity.getUsername()) .groups(groupRepository.getGroupsByIds(entity.getGroupIds())) .build(); @@ -31,9 +31,9 @@ public User createDto(UserEntity entity) { @Override public UserEntity findEntity(User dto) { - UserEntity userEntity = userRepository.findByUserIdAndUsername(dto.getId(), dto.getUsername()); + UserEntity userEntity = userRepository.findByUserIdAndUsername(dto.getUserId(), dto.getUsername()); if (null == userEntity) - throw new UserNotFoundException(dto.getId()); + throw new UserNotFoundException(dto.getUserId()); return userEntity; } diff --git a/src/main/java/de/filefighter/rest/domain/user/data/dto/User.java b/src/main/java/de/filefighter/rest/domain/user/data/dto/User.java index 710227f4..18c421ea 100644 --- a/src/main/java/de/filefighter/rest/domain/user/data/dto/User.java +++ b/src/main/java/de/filefighter/rest/domain/user/data/dto/User.java @@ -7,12 +7,12 @@ @Data @Builder public class User { - private long id; + private long userId; private String username; private Groups[] groups; - public User(long id, String username, Groups... groups) { - this.id = id; + public User(long userId, String username, Groups... groups) { + this.userId = userId; this.username = username; this.groups = groups; } diff --git a/src/test/java/de/filefighter/rest/cucumber/CommonCucumberSteps.java b/src/test/java/de/filefighter/rest/cucumber/CommonCucumberSteps.java index a83a16fd..4b59e9d3 100644 --- a/src/test/java/de/filefighter/rest/cucumber/CommonCucumberSteps.java +++ b/src/test/java/de/filefighter/rest/cucumber/CommonCucumberSteps.java @@ -56,7 +56,7 @@ public void userExists(long userId) { .build())); } - @And("user with id {long} exists and has username {string}, password {string} and refreshToken {string}") + @And("user with userId {long} exists and has username {string}, password {string} and refreshToken {string}") public void userWithIdExistsAndHasUsernamePasswordAndRefreshToken(long userId, String username, String password, String refreshTokenValue) { LOG.info("Creating User: " + userRepository.save(UserEntity .builder() @@ -68,7 +68,7 @@ public void userWithIdExistsAndHasUsernamePasswordAndRefreshToken(long userId, S .build())); } - @And("user with id {long} exists and has username {string}, password {string}") + @And("user with userId {long} exists and has username {string}, password {string}") public void userWithIdExistsAndHasUsernamePassword(long userId, String username, String password) { LOG.info("Creating User: " + userRepository.save(UserEntity .builder() @@ -82,7 +82,7 @@ public void userWithIdExistsAndHasUsernamePassword(long userId, String username, @Autowired MongoTemplate mongoTemplate; - @And("user with id {long} is in group with id {long}") + @And("user with userId {long} is in group with groupId {long}") public void userWithIdIsInGroupWithId(long userId, long groupId) { Query query = new Query(); Update newUpdate = new Update().set("groupIds", new long[]{groupId}); @@ -92,7 +92,7 @@ public void userWithIdIsInGroupWithId(long userId, long groupId) { } // This step almost needs a unit test. - @Given("{string} exists with id {long} and path {string}") + @Given("{string} exists with fileSystemId {long} and path {string}") public void fileOrFolderExistsWithIdAndPath(String fileOrFolder, long fsItemId, String path) { String[] names = path.split("/"); StringBuilder completeFilePath = new StringBuilder("/"); @@ -126,14 +126,14 @@ public void fileOrFolderExistsWithIdAndPath(String fileOrFolder, long fsItemId, fileSystemRepository.save(FileSystemEntity .builder() .isFile(true) - .id(fsItemId) + .fileSystemId(fsItemId) .build()); } else if (fileOrFolder.equals("folder")) { completeFilePath.append(names[i]).append("/"); fileSystemRepository.save(FileSystemEntity .builder() .isFile(false) - .id(fsItemId) + .fileSystemId(fsItemId) .path(completeFilePath.toString()) .build()); } else { @@ -144,9 +144,9 @@ public void fileOrFolderExistsWithIdAndPath(String fileOrFolder, long fsItemId, } } - @And("user {long} is owner of file or folder with id {long}") + @And("user {long} is owner of file or folder with fileSystemId {long}") public void userIsOwnerOfFileOrFolderWithId(long userId, long fsItemId) { - FileSystemEntity fileSystemEntity = fileSystemRepository.findById(fsItemId); + FileSystemEntity fileSystemEntity = fileSystemRepository.findByFileSystemId(fsItemId); fileSystemEntity.setCreatedByUserId(userId); fileSystemRepository.save(fileSystemEntity); @@ -161,10 +161,10 @@ public void responseContainsKeyAndValue(String key, String value) throws JsonPro assertEquals(value, actualValue); } - @And("response contains the user with id {long}") + @And("response contains the user with userId {long}") public void responseContainsTheUserWithId(long userId) throws JsonProcessingException { JsonNode rootNode = objectMapper.readTree(latestResponse.getBody()); - long actualValue = rootNode.get("id").asLong(); + long actualValue = rootNode.get("userId").asLong(); assertEquals(userId, actualValue); } diff --git a/src/test/java/de/filefighter/rest/cucumber/UserAuthorizationSteps.java b/src/test/java/de/filefighter/rest/cucumber/UserAuthorizationSteps.java index b7543f1b..62ccee5e 100644 --- a/src/test/java/de/filefighter/rest/cucumber/UserAuthorizationSteps.java +++ b/src/test/java/de/filefighter/rest/cucumber/UserAuthorizationSteps.java @@ -104,12 +104,12 @@ public void responseContainsValidAccessTokenForUser(long userId) throws JsonProc assertEquals(userId, actualUserId); } - @And("response contains refreshToken {string} and the user with id {long}") + @And("response contains refreshToken {string} and the user with userId {long}") public void responseContainsRefreshTokenAndTheUserWithId(String refreshToken, long userId) throws JsonProcessingException { JsonNode rootNode = objectMapper.readTree(latestResponse.getBody()); String actualRefreshToken = rootNode.get("tokenValue").asText(); JsonNode userNode = rootNode.get("user"); - long actualUserId = userNode.get("id").asLong(); + long actualUserId = userNode.get("userId").asLong(); assertEquals(userId, actualUserId); assertEquals(refreshToken, actualRefreshToken); diff --git a/src/test/java/de/filefighter/rest/cucumber/UserEditInformationSteps.java b/src/test/java/de/filefighter/rest/cucumber/UserEditInformationSteps.java index b2f4d708..5b74f5fd 100644 --- a/src/test/java/de/filefighter/rest/cucumber/UserEditInformationSteps.java +++ b/src/test/java/de/filefighter/rest/cucumber/UserEditInformationSteps.java @@ -1,7 +1,6 @@ package de.filefighter.rest.cucumber; import de.filefighter.rest.RestApplicationIntegrationTest; -import de.filefighter.rest.TestUtils; import io.cucumber.java.en.When; import org.springframework.http.HttpMethod; @@ -11,6 +10,7 @@ import static de.filefighter.rest.configuration.RestConfiguration.*; public class UserEditInformationSteps extends RestApplicationIntegrationTest { + @When("user requests change of username with value {string} userId {long} and accessToken {string}") public void userRequestsChangeOfUsernameWithValueAndAccessTokenAndId(String newUsername, long userId, String accessToken) { String authHeaderString = AUTHORIZATION_BEARER_PREFIX + accessToken; diff --git a/src/test/java/de/filefighter/rest/cucumber/ViewFolderContentsSteps.java b/src/test/java/de/filefighter/rest/cucumber/ViewFolderContentsSteps.java index 8460e3a0..decd45d2 100644 --- a/src/test/java/de/filefighter/rest/cucumber/ViewFolderContentsSteps.java +++ b/src/test/java/de/filefighter/rest/cucumber/ViewFolderContentsSteps.java @@ -5,11 +5,12 @@ import io.cucumber.java.en.When; public class ViewFolderContentsSteps extends RestApplicationIntegrationTest { + @When("user with token {string} wants to see the content of folder with path {string}") public void userWithTokenWantsToSeeTheContentOfFolderWithPath(String accessTokenValue, String path) { } - @And("the response contains the file with id {long} and name {string}") + @And("the response contains the file with fileSystemId {long} and name {string}") public void theResponseContainsTheFileWithIdAndName(long fsItemId , String name) { } diff --git a/src/test/java/de/filefighter/rest/domain/token/business/AccessTokenBusinessServiceUnitTest.java b/src/test/java/de/filefighter/rest/domain/token/business/AccessTokenBusinessServiceUnitTest.java index 1cce51be..0596669b 100644 --- a/src/test/java/de/filefighter/rest/domain/token/business/AccessTokenBusinessServiceUnitTest.java +++ b/src/test/java/de/filefighter/rest/domain/token/business/AccessTokenBusinessServiceUnitTest.java @@ -30,7 +30,7 @@ void setUp() { @Test void getValidAccessTokenForUserWhenNoTokenExists() { long dummyId = 1234; - User dummyUser = User.builder().id(dummyId).build(); + User dummyUser = User.builder().userId(dummyId).build(); AccessToken dummyAccessToken = AccessToken.builder().userId(dummyId).build(); AccessTokenEntity dummyAccessTokenEntity = AccessTokenEntity.builder().userId(dummyId).build(); @@ -45,7 +45,7 @@ void getValidAccessTokenForUserWhenNoTokenExists() { @Test void getValidAccessTokenForUserWhenTokenExists() { long dummyId = 1234; - User dummyUser = User.builder().id(dummyId).build(); + User dummyUser = User.builder().userId(dummyId).build(); AccessToken dummyAccessToken = AccessToken.builder().userId(dummyId).build(); AccessTokenEntity dummyAccessTokenEntity = AccessTokenEntity .builder() @@ -63,7 +63,7 @@ void getValidAccessTokenForUserWhenTokenExists() { @Test void getValidAccessTokenForUserWhenTokenExistsButIsInvalid() { long dummyId = 1234; - User dummyUser = User.builder().id(dummyId).build(); + User dummyUser = User.builder().userId(dummyId).build(); AccessToken dummyAccessToken = AccessToken.builder().userId(dummyId).build(); AccessTokenEntity dummyAccessTokenEntity = AccessTokenEntity .builder() @@ -85,7 +85,7 @@ void getValidAccessTokenForUserWhenTokenExistsButIsInvalid() { @Test void getValidAccessTokenForUserWhenTokenDeletionFails() { long dummyId = 1234; - User dummyUser = User.builder().id(dummyId).build(); + User dummyUser = User.builder().userId(dummyId).build(); AccessTokenEntity dummyAccessTokenEntity = AccessTokenEntity .builder() .userId(dummyId) diff --git a/src/test/java/de/filefighter/rest/domain/user/business/UserBusinessServiceUnitTest.java b/src/test/java/de/filefighter/rest/domain/user/business/UserBusinessServiceUnitTest.java index 19aaff5a..dbee6b53 100644 --- a/src/test/java/de/filefighter/rest/domain/user/business/UserBusinessServiceUnitTest.java +++ b/src/test/java/de/filefighter/rest/domain/user/business/UserBusinessServiceUnitTest.java @@ -58,7 +58,7 @@ void getRefreshTokenForUserWithoutUser() { long userId = 420; String username = "someString"; - User dummyUser = User.builder().id(userId).username(username).build(); + User dummyUser = User.builder().userId(userId).username(username).build(); when(userRepositoryMock.findByUserIdAndUsername(userId, username)).thenReturn(null); @@ -74,7 +74,7 @@ void getRefreshTokenForUserWithInvalidString() { long userId = 420; String username = "someString"; - User dummyUser = User.builder().id(userId).username(username).build(); + User dummyUser = User.builder().userId(userId).username(username).build(); UserEntity dummyEntity = UserEntity.builder().refreshToken(invalidString).build(); when(userRepositoryMock.findByUserIdAndUsername(userId, username)).thenReturn(dummyEntity); @@ -91,7 +91,7 @@ void getCorrectRefreshTokenForUser() { long userId = 420; String username = "someString"; String refreshToken = "someToken"; - User dummyUser = User.builder().id(userId).username(username).build(); + User dummyUser = User.builder().userId(userId).username(username).build(); UserEntity dummyEntity = UserEntity.builder().refreshToken(refreshToken).build(); RefreshToken expected = RefreshToken.builder().tokenValue(refreshToken).user(dummyUser).build(); @@ -300,7 +300,7 @@ void updateUserThrows() { void updateUserNameThrows() { final UserRegisterForm userRegisterForm = UserRegisterForm.builder().build(); long userId = 420; - User authenticatedUser = User.builder().id(userId).groups(new Groups[]{Groups.FAMILY}).build(); + User authenticatedUser = User.builder().userId(userId).groups(new Groups[]{Groups.FAMILY}).build(); UserEntity dummyEntity = UserEntity.builder().build(); when(userRepositoryMock.findByUserId(userId)).thenReturn(userEntityMock); @@ -323,7 +323,7 @@ void updateUserNameThrows() { void updateUserNameWorks() { final UserRegisterForm userRegisterForm = UserRegisterForm.builder().username("newUserName").build(); long userId = 420; - User authenticatedUser = User.builder().id(userId).groups(new Groups[]{Groups.FAMILY}).build(); + User authenticatedUser = User.builder().userId(userId).groups(new Groups[]{Groups.FAMILY}).build(); when(userRepositoryMock.findByUserId(userId)).thenReturn(userEntityMock); @@ -334,7 +334,7 @@ void updateUserNameWorks() { void updatePasswordThrows() { final UserRegisterForm userRegisterForm = UserRegisterForm.builder().build(); long userId = 420; - User authenticatedUser = User.builder().id(userId).groups(new Groups[]{Groups.FAMILY}).build(); + User authenticatedUser = User.builder().userId(userId).groups(new Groups[]{Groups.FAMILY}).build(); UserEntity dummyEntity = UserEntity.builder().userId(userId).lowercaseUsername("password").build(); when(userRepositoryMock.findByUserId(userId)).thenReturn(userEntityMock); @@ -376,7 +376,7 @@ void updatePasswordWorks() { String password = "validPassword1234"; final UserRegisterForm userRegisterForm = UserRegisterForm.builder().password(password).confirmationPassword(password).build(); long userId = 420; - User authenticatedUser = User.builder().id(userId).groups(new Groups[]{Groups.FAMILY}).build(); + User authenticatedUser = User.builder().userId(userId).groups(new Groups[]{Groups.FAMILY}).build(); UserEntity dummyEntity = UserEntity.builder().userId(userId).lowercaseUsername("UGABUGA").build(); when(userRepositoryMock.findByUserId(userId)).thenReturn(dummyEntity); @@ -387,7 +387,7 @@ void updatePasswordWorks() { void updateGroupsThrows() { final UserRegisterForm userRegisterForm = UserRegisterForm.builder().build(); long userId = 420; - User authenticatedUser = User.builder().id(userId).groups(new Groups[]{Groups.FAMILY}).build(); + User authenticatedUser = User.builder().userId(userId).groups(new Groups[]{Groups.FAMILY}).build(); UserEntity dummyEntity = UserEntity.builder().userId(userId).lowercaseUsername("password").build(); long[] groups = new long[]{0}; @@ -411,7 +411,7 @@ void updateGroupsThrows() { void updateGroupsWorks() { final UserRegisterForm userRegisterForm = UserRegisterForm.builder().build(); long userId = 420; - User authenticatedUser = User.builder().id(userId).groups(new Groups[]{Groups.FAMILY}).build(); + User authenticatedUser = User.builder().userId(userId).groups(new Groups[]{Groups.FAMILY}).build(); UserEntity dummyEntity = UserEntity.builder().userId(userId).lowercaseUsername("password").build(); long[] groups = new long[]{0}; diff --git a/src/test/java/de/filefighter/rest/domain/user/business/UserDtoServiceUnitTest.java b/src/test/java/de/filefighter/rest/domain/user/business/UserDtoServiceUnitTest.java index 179ceae0..e3baaf1a 100644 --- a/src/test/java/de/filefighter/rest/domain/user/business/UserDtoServiceUnitTest.java +++ b/src/test/java/de/filefighter/rest/domain/user/business/UserDtoServiceUnitTest.java @@ -35,7 +35,7 @@ void createDto() { when(groupRepositoryMock.getGroupsByIds(groups)).thenReturn(new Groups[]{Groups.FAMILY}); User actualUser = userDtoService.createDto(dummyEntity); - assertEquals(userId, actualUser.getId()); + assertEquals(userId, actualUser.getUserId()); assertEquals(username, actualUser.getUsername()); assertEquals(groups[0], actualUser.getGroups()[0].getGroupId()); } @@ -44,7 +44,7 @@ void createDto() { void findEntityThrowsException() { long userId = 0; String username = "kevin"; - User user = User.builder().username(username).id(userId).build(); + User user = User.builder().username(username).userId(userId).build(); when(userRepositoryMock.findByUserIdAndUsername(userId, username)).thenReturn(null); @@ -57,7 +57,7 @@ void findEntityThrowsException() { void findEntityWorksCorrectly() { long userId = 0; String username = "kevin"; - User user = User.builder().username(username).id(userId).build(); + User user = User.builder().username(username).userId(userId).build(); UserEntity expected = UserEntity.builder().username(username).userId(userId).build(); when(userRepositoryMock.findByUserIdAndUsername(userId, username)).thenReturn(expected); diff --git a/src/test/java/de/filefighter/rest/domain/user/rest/UserRestControllerUnitTest.java b/src/test/java/de/filefighter/rest/domain/user/rest/UserRestControllerUnitTest.java index 0a31f007..9229c9bc 100644 --- a/src/test/java/de/filefighter/rest/domain/user/rest/UserRestControllerUnitTest.java +++ b/src/test/java/de/filefighter/rest/domain/user/rest/UserRestControllerUnitTest.java @@ -40,7 +40,7 @@ void registerNewUser() { @Test void loginUserWithUsernameAndPassword() { - User user = User.builder().id(420).groups(null).username("kevin").build(); + User user = User.builder().userId(420).groups(null).username("kevin").build(); RefreshToken refreshToken = RefreshToken.builder().tokenValue("token").user(user).build(); ResponseEntity expectedRefreshToken = new ResponseEntity<>(refreshToken, OK); @@ -64,7 +64,7 @@ void getAccessTokenAndUserInfoByRefreshTokenAndUserId() { @Test void getUserInfoWithAccessToken() { - User user = User.builder().id(420).groups(null).username("kevin").build(); + User user = User.builder().userId(420).groups(null).username("kevin").build(); ResponseEntity expectedUser = new ResponseEntity<>(user, OK); when(userRestServiceMock.getUserByUserIdAuthenticateWithAccessToken("token", 420)).thenReturn(expectedUser); @@ -86,7 +86,7 @@ void updateUserWithAccessToken() { @Test void findUserByUsername(){ - User user = User.builder().id(420).groups(null).username("kevin").build(); + User user = User.builder().userId(420).groups(null).username("kevin").build(); ResponseEntity expectedUser = new ResponseEntity<>(user, OK); String username="kevin"; diff --git a/src/test/resources/FindUser.feature b/src/test/resources/FindUser.feature index 94a150df..f0d416e2 100644 --- a/src/test/resources/FindUser.feature +++ b/src/test/resources/FindUser.feature @@ -4,25 +4,25 @@ Feature: Find User with Username Background: Given database is empty - And user with id 1234 exists and has username "kangaroo", password "pig-system" + And user with userId 1234 exists and has username "kangaroo", password "pig-system" And accessToken with value "accessToken1" exists for user 1234 - And user with id 1235 exists and has username "penguin", password "i-love-capitalism" + And user with userId 1235 exists and has username "penguin", password "i-love-capitalism" And accessToken with value "accessToken2" exists for user 1235 Scenario: Successful find another user When user with accessToken "accessToken1" searches user with search-value "penguin" Then response status code is 200 - And response contains the user with id 1235 + And response contains the user with userId 1235 Scenario: Successful find another user with username in wrong case When user with accessToken "accessToken1" searches user with search-value "PeNgUiN" Then response status code is 200 - And response contains the user with id 1235 + And response contains the user with userId 1235 Scenario: Successful find another user with username including some spaces When user with accessToken "accessToken1" searches user with search-value " pen guin " Then response status code is 200 - And response contains the user with id 1235 + And response contains the user with userId 1235 Scenario: Failed to find another user because username has spelling errors When user with accessToken "accessToken1" searches user with search-value "benguin" diff --git a/src/test/resources/SystemHealth.feature b/src/test/resources/SystemHealth.feature index e4372c63..2a445e5e 100644 --- a/src/test/resources/SystemHealth.feature +++ b/src/test/resources/SystemHealth.feature @@ -23,8 +23,8 @@ Scenario: SystemHealth is requested with users in db Scenario: SystemHealth is Unstable Given accessToken with value "token" exists for user 1234 - And user with id 1234 exists and has username "user", password "pw" - And user with id 1234 exists and has username "user", password "pw" + And user with userId 1234 exists and has username "user", password "pw" + And user with userId 1234 exists and has username "user", password "pw" When user with accessToken "token" searches user with search-value "user" And response status code is 500 And the systemHealth endpoint is requested diff --git a/src/test/resources/UserAuthorization.feature b/src/test/resources/UserAuthorization.feature index a4dd3659..2a0ecbd6 100644 --- a/src/test/resources/UserAuthorization.feature +++ b/src/test/resources/UserAuthorization.feature @@ -5,22 +5,22 @@ Feature: User Authorization Background: Given database is empty - And user with id 1234 exists and has username "user", password "secure_password" and refreshToken "token" + And user with userId 1234 exists and has username "user", password "secure_password" and refreshToken "token" Scenario: Successful login with username and password. When user requests login with username "user" and password "secure_password" Then response status code is 200 - And response contains refreshToken "token" and the user with id 1234 + And response contains refreshToken "token" and the user with userId 1234 Scenario: Successful login with username in different Case and password. When user requests login with username "UsEr" and password "secure_password" Then response status code is 200 - And response contains refreshToken "token" and the user with id 1234 + And response contains refreshToken "token" and the user with userId 1234 Scenario: Successful login with username in different Case, whiteSpaces and password. When user requests login with username "U s E r" and password "secure_password" Then response status code is 200 - And response contains refreshToken "token" and the user with id 1234 + And response contains refreshToken "token" and the user with userId 1234 Scenario: Failed login with wrong username or password. When user requests login with username "user" and password "wrong_password" @@ -58,7 +58,7 @@ Scenario: Successful retrieval of overwritten accessToken with refreshToken Scenario: Successful UserInfo request with valid accessToken. Given accessToken with value "6bb9cb4f-7b51-4c0a-8013-ed7a34e56282" exists for user 1234 When user requests userInfo with accessToken "6bb9cb4f-7b51-4c0a-8013-ed7a34e56282" and userId 1234 - Then response contains the user with id 1234 + Then response contains the user with userId 1234 And response status code is 200 Scenario: Failed UserInfo request with invalid accessToken. diff --git a/src/test/resources/UserEditInformation.feature b/src/test/resources/UserEditInformation.feature index e7301a5b..572a03f5 100644 --- a/src/test/resources/UserEditInformation.feature +++ b/src/test/resources/UserEditInformation.feature @@ -4,7 +4,7 @@ Feature: Edit User Details Background: Given database is empty - And user with id 1234 exists and has username "user", password "secure_password" and refreshToken "refreshToken1234" + And user with userId 1234 exists and has username "user", password "secure_password" and refreshToken "refreshToken1234" And accessToken with value "accessToken" exists for user 1234 Scenario: Successful change of username @@ -20,7 +20,7 @@ Feature: Edit User Details And response status code is 201 Scenario: Failed change of username; new username already assigned - Given user with id 1235 exists and has username "kangaroo", password "secure_password" + Given user with userId 1235 exists and has username "kangaroo", password "secure_password" When user requests change of username with value "kangaroo" userId 1234 and accessToken "accessToken" Then response contains key "message" and value "User could not get updated. Username already taken." And response status code is 409 diff --git a/src/test/resources/UserRegistration.feature b/src/test/resources/UserRegistration.feature index 05fe2884..86d14e81 100644 --- a/src/test/resources/UserRegistration.feature +++ b/src/test/resources/UserRegistration.feature @@ -4,9 +4,9 @@ Feature: User Registration Background: Given database is empty - And user with id 1234 exists and has username "user", password "Secure_password1" + And user with userId 1234 exists and has username "user", password "Secure_password1" And accessToken with value "accessToken" exists for user 1234 - And user with id 1234 is in group with id 1 + And user with userId 1234 is in group with groupId 1 Scenario: Failed registration because password does not match requirements. When user requests registration with username "kangaroo", password "short" and password confirmation "short" with accessToken "accessToken" @@ -52,7 +52,7 @@ Feature: User Registration Scenario: Failed registration with username, password and password confirmation; not in group ADMIN Given user 1236 exists - And user with id 1236 is in group with id -1 + And user with userId 1236 is in group with groupId -1 And accessToken with value "wrongAccessToken" exists for user 1236 When user requests registration with username "kangaroo", password "Pig-system12" and password confirmation "Pig-system12" with accessToken "wrongAccessToken" Then response status code is 401