@Test public void getSetTest() { MongoEndpointUserConfiguration mongoEndpointUserConfiguration = new MongoEndpointUserConfiguration(); String appToken = "appToken"; String body = "body"; int schemaVersion = 2; String userId = "userId"; mongoEndpointUserConfiguration.setAppToken(appToken); mongoEndpointUserConfiguration.setBody(body); mongoEndpointUserConfiguration.setSchemaVersion(schemaVersion); mongoEndpointUserConfiguration.setUserId(userId); Assert.assertEquals(appToken, mongoEndpointUserConfiguration.getAppToken()); Assert.assertEquals(body, mongoEndpointUserConfiguration.getBody()); Assert.assertTrue(schemaVersion == mongoEndpointUserConfiguration.getSchemaVersion()); Assert.assertEquals(userId, mongoEndpointUserConfiguration.getUserId()); } }
@Test public void saveEndpointUserConfigurationDtoTest() throws IOException { EndpointUserConfigurationDto userConfigurationDto = generateEndpointUserConfigurationDto(null, null, null, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON)); Assert.assertNotNull(userConfigurationDto); Assert.assertEquals(userConfigurationDto, new MongoEndpointUserConfiguration(userConfigurationDto).toDto()); }
@Override public MongoEndpointUserConfiguration save(EndpointUserConfigurationDto dto) { LOG.debug("Saving user specific configuration {}", dto); MongoEndpointUserConfiguration userConfiguration = save( new MongoEndpointUserConfiguration(dto)); if (LOG.isTraceEnabled()) { LOG.trace("Saving result: {}", userConfiguration); } else { LOG.debug("Saving result: {}", userConfiguration != null); } return userConfiguration; }
@Test public void findByUserIdAndAppTokenAndSchemaVersionTest() throws IOException { EndpointUserDto userDto = generateEndpointUserDto(null); ApplicationDto appDto = generateApplicationDto(); ConfigurationSchemaDto schema = generateConfSchemaDto(null, appDto.getId(), 1).get(0); EndpointUserConfigurationDto firstUserConfigurationDto = generateEndpointUserConfigurationDto(userDto, appDto, schema, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON)); generateEndpointUserConfigurationDto(userDto, appDto, null, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON)); generateEndpointUserConfigurationDto(null, null, null, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON)); MongoEndpointUserConfiguration found = endpointUserConfigurationDao.findByUserIdAndAppTokenAndSchemaVersion(userDto.getId(), appDto.getApplicationToken(), schema.getVersion()); Assert.assertEquals(firstUserConfigurationDto, found.toDto()); }
@Test @Ignore("invalid") public void findByUserIdTest() throws IOException { EndpointUserDto userDto = generateEndpointUserDto(null); ApplicationDto appDto = generateApplicationDto(); EndpointUserConfigurationDto firstUserConfigurationDto = generateEndpointUserConfigurationDto(userDto, appDto, null, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON)); EndpointUserConfigurationDto secondUserConfigurationDto = generateEndpointUserConfigurationDto(userDto, appDto, null, readSchemaFileAsString(OVERRIDE_USER_DATA_JSON)); List<MongoEndpointUserConfiguration> expectedList = new ArrayList<>(); expectedList.add(new MongoEndpointUserConfiguration(firstUserConfigurationDto)); expectedList.add(new MongoEndpointUserConfiguration(secondUserConfigurationDto)); generateEndpointUserConfigurationDto(null, null, null); List<MongoEndpointUserConfiguration> foundList = endpointUserConfigurationDao.findByUserId(userDto.getId()); Assert.assertEquals(expectedList.size(), foundList.size()); Assert.assertEquals(expectedList, foundList); } }