use of org.summerb.microservices.properties.api.dto.NamedProperty in project summerb by skarpushin.
the class PropertyServiceImpl method putSubjectProperties.
@Transactional(rollbackFor = Throwable.class)
@Override
public void putSubjectProperties(String appName, String domainName, String subjectId, List<NamedProperty> namedProperties) {
if (CollectionUtils.isEmpty(namedProperties)) {
return;
}
checkArgumentsHaveText(appName, domainName, subjectId);
String currentPropertyName = null;
try {
long appId = appNameAlias.getAliasFor(appName);
long domainId = domainNameAlias.getAliasFor(domainName);
for (NamedProperty namedProperty : namedProperties) {
currentPropertyName = namedProperty.getName();
long propertyNameId = propertyNameAlias.getAliasFor(currentPropertyName);
String value = namedProperty.getPropertyValue();
propertyDao.putProperty(appId, domainId, subjectId, propertyNameId, value);
}
} catch (Throwable t) {
propagatePropertyNameIfTruncationError(t, currentPropertyName);
throw new PropertyServiceUnexpectedException("Failed to put subject properties", t);
}
}
use of org.summerb.microservices.properties.api.dto.NamedProperty in project summerb by skarpushin.
the class PropertyServiceImplTest method testPutSubjectProperties_whitebox_expectCorretPropertyNames.
@Test
public void testPutSubjectProperties_whitebox_expectCorretPropertyNames() throws Exception {
List<NamedProperty> propList = new ArrayList<NamedProperty>();
propList.add(new NamedProperty("some.property1", "value1"));
propList.add(new NamedProperty("some.property2", "value2"));
propertyService.putSubjectProperties("test", "test.domain", "1", propList);
propertyService.putSubjectProperty("test", "test.domain", "2", "some.property1", "value3");
Map<String, String> result = propertyService.findSubjectProperties("test", "test.domain", "1");
assertTrue(result.containsKey("some.property1"));
assertTrue(result.containsKey("some.property2"));
}
use of org.summerb.microservices.properties.api.dto.NamedProperty in project summerb by skarpushin.
the class PropertyServiceImplTest method testPutProperty_expectTruncationExceptionForPropertyNameForMultipleProperties.
@Test
public void testPutProperty_expectTruncationExceptionForPropertyNameForMultipleProperties() {
String propertyName = "some.property1";
List<NamedProperty> props = new ArrayList<NamedProperty>();
props.add(new NamedProperty("n1", "vvv1"));
props.add(new NamedProperty(propertyName, generateLongString(256, "прол")));
props.add(new NamedProperty("n2", "vvv2"));
try {
propertyService.putSubjectProperties("test", "test.domain", "AAA", props);
} catch (Throwable t) {
String foundName = DaoExceptionUtils.findTruncatedFieldNameIfAny(t);
assertEquals(propertyName, foundName);
}
}
Aggregations