Skip to content

Commit

Permalink
KAA-1337: Add REST API to retrieve a configuration of a specific user…
Browse files Browse the repository at this point in the history
… by its external id.
  • Loading branch information
Pyshankov committed Aug 17, 2016
1 parent 661d583 commit 1f1511d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
Expand Up @@ -127,13 +127,14 @@ public void removeByUserIdAndAppTokenAndSchemaVersion(String userId, String appT
@Override
public EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(
String externalUid,
String appToken,
Integer schemaVersion,
String tenantId) {
EndpointUser endpointUser = endpointUserDao.findByExternalIdAndTenantId(externalUid,tenantId);
EndpointUserConfiguration endpointUserConfiguration =
endpointUserConfigurationDao.findByUserIdAndAppTokenAndSchemaVersion(endpointUser.getId(),appToken,schemaVersion);
return getDto(endpointUserConfiguration);
String appToken,
Integer schemaVersion,
String tenantId) {
return getDto(
endpointUserConfigurationDao.findByUserIdAndAppTokenAndSchemaVersion(
endpointUserDao.findByExternalIdAndTenantId(externalUid, tenantId).getId(),
appToken,
schemaVersion));
}


Expand Down
Expand Up @@ -83,22 +83,35 @@ public void removeByUserIdAndAppTokenAndSchemaVersionTest() throws IOException {
}

@Test
public void findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersionTest() throws IOException{
public void findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersionTest() throws IOException{
ApplicationDto appDto = generateApplicationDto();
EndpointUserDto userDto = generateEndpointUserDto(appDto.getTenantId());
EndpointUserConfigurationDto userConfigurationDto =
generateEndpointUserConfigurationDto(userDto, appDto, null, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON));

EndpointUserConfigurationDto endpointUserConfigurationDto =
userConfigurationService.findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(
userDto.getExternalId(),
appDto.getApplicationToken(),
userConfigurationDto.getSchemaVersion(),
appDto.getTenantId()
);
appDto.getTenantId());
Assert.assertNotNull(endpointUserConfigurationDto);
}

@Test
public void findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersionNullTest() throws IOException{
ApplicationDto appDto = generateApplicationDto();
EndpointUserDto userDto = generateEndpointUserDto(appDto.getTenantId());
EndpointUserConfigurationDto userConfigurationDto = generateEndpointUserConfigurationDto(userDto, appDto, null, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON));
userConfigurationService.removeByUserIdAndAppTokenAndSchemaVersion(userDto.getId(), appDto.getApplicationToken(), userConfigurationDto.getSchemaVersion());
EndpointUserConfigurationDto endpointUserConfigurationDto =
userConfigurationService.findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(
userDto.getExternalId(),
appDto.getApplicationToken(),
userConfigurationDto.getSchemaVersion(),
appDto.getTenantId());
Assert.assertNull(endpointUserConfigurationDto);
}

@Test
public void saveUserConfigurationTest() throws IOException {
EndpointUserConfigurationDto configurationDto = generateEndpointUserConfigurationDto(null, null, null, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON));
Expand Down
Expand Up @@ -291,13 +291,14 @@ public List<UserDto> findAllTenantAdminsByTenantId(
}

@ApiOperation(value = "Get endpoint user configuration by external user id",
notes="Get endpoint user configuration by external user id. Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform this operation.")
notes="Get endpoint user configuration by external user id." +
" Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The specified url is not valid"),
@ApiResponse(code = 400, message = "The specified url is not valid"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have neither TENANT_DEVELOPER nor TENANT_USER role"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configuration/{appToken}/{userId}/{schemaVersion}", method = RequestMethod.GET)
@RequestMapping(value = "configuration/{userId}/{appToken}/{schemaVersion}", method = RequestMethod.GET)
@ResponseBody
public EndpointUserConfigurationDto findUserConfigurationByUserId(
@PathVariable String userId,
Expand All @@ -306,10 +307,4 @@ public EndpointUserConfigurationDto findUserConfigurationByUserId(
return configurationService.findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(userId,appToken,schemaVersion);
}







}

0 comments on commit 1f1511d

Please sign in to comment.