use of com.bakdata.conquery.models.identifiable.IdentifiableImpl in project conquery by bakdata.
the class SerializationTestUtil method test.
private void test(T value, T expected, ObjectMapper mapper) throws IOException {
if (registry != null) {
mapper = new SingletonNamespaceCollection(registry, registry).injectIntoNew(mapper);
}
for (Injectable injectable : injectables) {
mapper = injectable.injectIntoNew(mapper);
}
ObjectWriter writer = mapper.writerFor(type).withView(InternalOnly.class);
ObjectReader reader = mapper.readerFor(type).withView(InternalOnly.class);
ValidatorHelper.failOnError(log, validator.validate(value));
byte[] src = writer.writeValueAsBytes(value);
T copy = reader.readValue(src);
if (expected == null && copy == null) {
return;
}
ValidatorHelper.failOnError(log, validator.validate(copy));
// because IdentifiableImp cashes the hash
if (value instanceof IdentifiableImpl) {
assertThat(copy.hashCode()).isEqualTo(value.hashCode());
}
RecursiveComparisonAssert<?> ass = assertThat(copy).as("Unequal after copy.").usingRecursiveComparison();
ass.isEqualTo(expected);
}
use of com.bakdata.conquery.models.identifiable.IdentifiableImpl in project conquery by bakdata.
the class FrontEndConceptBuilder method createCTNode.
private static FENode createCTNode(ConceptElement<?> ce) {
MatchingStats matchingStats = ce.getMatchingStats();
FENode n = FENode.builder().active(null).description(ce.getDescription()).label(ce.getLabel()).additionalInfos(ce.getAdditionalInfos()).matchingEntries(matchingStats.countEvents()).matchingEntities(matchingStats.countEntities()).dateRange(matchingStats.spanEvents() != null ? matchingStats.spanEvents().toSimpleRange() : null).build();
if (ce instanceof ConceptTreeNode) {
ConceptTreeNode<?> tree = (ConceptTreeNode<?>) ce;
if (tree.getChildren() != null) {
n.setChildren(tree.getChildren().stream().map(IdentifiableImpl::getId).toArray(ConceptTreeChildId[]::new));
}
if (tree.getParent() != null) {
n.setParent(tree.getParent().getId());
}
}
return n;
}
Aggregations