use of com.icthh.xm.ms.entity.domain.spec.TagSpec in project xm-ms-entity by xm-online.
the class XmEntityGeneratorService method generateTags.
private Set<Tag> generateTags(TypeSpec typeSpec) {
Set<Tag> tags = new HashSet<>();
for (TagSpec tagSpec : randomCollectionElement(typeSpec.getTags())) {
int countTags = RandomUtils.nextInt(1, MAX_TAGS_BY_TYPE);
IntStream.range(0, countTags).forEach(i -> tags.add(createTag(tagSpec, i + 1)));
log.debug("Generate {} tags for type {}", countTags, tagSpec.getKey());
}
return tags;
}
use of com.icthh.xm.ms.entity.domain.spec.TagSpec in project xm-ms-entity by xm-online.
the class XmEntityGeneratorServiceIntTest method generateXmEntityWithTagsTest.
@Test
@SneakyThrows
public void generateXmEntityWithTagsTest() {
XmEntity generatedEntity = xmEntityGeneratorService.generateXmEntity(ENTITY_TYPE_WITH_TAGS_AND_LOCATIONS_KEY);
log.info(new ObjectMapper().writeValueAsString(generatedEntity));
Set<Tag> tags = generatedEntity.getTags();
assertFalse("No tags generated", isEmpty(tags));
TypeSpec specType = xmEntitySpecService.findTypeByKey("TYPE1.SUBTYPE1");
List<TagSpec> tagsSpecs = specType.getTags();
Set<String> specTagsKeys = tagsSpecs.stream().map(TagSpec::getKey).collect(toSet());
Set<String> tagsKeys = tags.stream().map(Tag::getTypeKey).collect(toSet());
assertTrue("Tag type not from tag specification", specTagsKeys.containsAll(tagsKeys));
for (val tag : tags) {
assertFalse("Name of tag is empty", isBlank(tag.getName()));
}
}
Aggregations