use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.
the class AuthoritativeSourceResolverTest method existingEntriesThenReturnsMostSpecificRating.
@Test
public void existingEntriesThenReturnsMostSpecificRating() {
List<AuthoritativeRatingVantagePoint> vantagePoints = new ArrayList<>();
vantagePoints.add(ImmutableAuthoritativeRatingVantagePoint.builder().vantagePoint(vantagePoint).rank(1).dataTypeCode("REF_DATA").applicationId(205L).rating(AuthoritativenessRating.PRIMARY).build());
vantagePoints.add(ImmutableAuthoritativeRatingVantagePoint.builder().vantagePoint(vantagePoint).rank(2).dataTypeCode("REF_DATA").applicationId(200L).rating(AuthoritativenessRating.SECONDARY).build());
AuthoritativeSourceResolver authoritativeSourceResolver = new AuthoritativeSourceResolver(vantagePoints);
AuthoritativenessRating rating = authoritativeSourceResolver.resolve(vantagePoint, sourceApp, "REF_DATA");
Assert.assertEquals(AuthoritativenessRating.SECONDARY, rating);
}
use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.
the class AuthoritativeSourceResolverTest method whenResolveWithMissingVantagePointThenReturnsNoOpinion.
@Test
public void whenResolveWithMissingVantagePointThenReturnsNoOpinion() {
List<AuthoritativeRatingVantagePoint> vantagePoints = new ArrayList<>();
AuthoritativeSourceResolver authoritativeSourceResolver = new AuthoritativeSourceResolver(vantagePoints);
AuthoritativenessRating rating = authoritativeSourceResolver.resolve(vantagePoint, sourceApp, "REF_DATA");
Assert.assertEquals(AuthoritativenessRating.NO_OPINION, rating);
}
use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.
the class AuthoritativeSourceResolverTest method whenResolveWithExistingVantageButMissingDataTypeThenReturnsNoOpinion.
@Test
public void whenResolveWithExistingVantageButMissingDataTypeThenReturnsNoOpinion() {
List<AuthoritativeRatingVantagePoint> vantagePoints = new ArrayList<>();
vantagePoints.add(ImmutableAuthoritativeRatingVantagePoint.builder().vantagePoint(vantagePoint).rank(1).dataTypeCode("TRADE_DATA").applicationId(200L).rating(AuthoritativenessRating.SECONDARY).build());
AuthoritativeSourceResolver authoritativeSourceResolver = new AuthoritativeSourceResolver(vantagePoints);
AuthoritativenessRating rating = authoritativeSourceResolver.resolve(vantagePoint, sourceApp, "REF_DATA");
Assert.assertEquals(AuthoritativenessRating.NO_OPINION, rating);
}
use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.
the class AuthoritativeSourceResolverTest method existingVantageAndDataTypeAndDifferentSourceThenDiscouraged.
@Test
public void existingVantageAndDataTypeAndDifferentSourceThenDiscouraged() {
List<AuthoritativeRatingVantagePoint> vantagePoints = new ArrayList<>();
vantagePoints.add(ImmutableAuthoritativeRatingVantagePoint.builder().vantagePoint(vantagePoint).rank(1).dataTypeCode("REF_DATA").applicationId(205L).rating(AuthoritativenessRating.PRIMARY).build());
AuthoritativeSourceResolver authoritativeSourceResolver = new AuthoritativeSourceResolver(vantagePoints);
AuthoritativenessRating rating = authoritativeSourceResolver.resolve(vantagePoint, sourceApp, "REF_DATA");
Assert.assertEquals(AuthoritativenessRating.DISCOURAGED, rating);
}
use of com.khartec.waltz.model.rating.AuthoritativenessRating in project waltz by khartec.
the class LogicalFlowDecoratorRatingsCalculator method calculate.
public Collection<LogicalFlowDecorator> calculate(Collection<LogicalFlowDecorator> decorators) {
List<LogicalFlow> flows = loadFlows(decorators).stream().filter(f -> f.target().kind() == EntityKind.APPLICATION && f.source().kind() == EntityKind.APPLICATION).collect(toList());
if (isEmpty(flows))
return Collections.emptyList();
List<Application> targetApps = loadTargetApplications(flows);
List<DataType> dataTypes = dataTypeDao.getAll();
Map<Long, DataType> typesById = indexById(dataTypes);
Map<Long, LogicalFlow> flowsById = indexById(flows);
Map<Long, Application> targetAppsById = indexById(targetApps);
AuthoritativeSourceResolver resolver = createResolver(targetApps);
return decorators.stream().map(decorator -> {
try {
if (decorator.decoratorEntity().kind() != EntityKind.DATA_TYPE) {
return decorator;
} else {
AuthoritativenessRating rating = lookupRating(typesById, flowsById, targetAppsById, resolver, decorator);
return ImmutableLogicalFlowDecorator.copyOf(decorator).withRating(rating);
}
} catch (Exception e) {
LOG.warn("Failed to calculate rating for decorator: {}, reason: {}", decorator, e.getMessage());
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toSet());
}
Aggregations