@Test public void resolvesWithDependentPropertiesCorrectlyWhenSomePropertiesMissing() throws Exception { Resource resource = createHttpUri("sx"); Collection<Statement> testInput = ImmutableList.of( createHttpStatement("sa", "d1", "oa1", "good"), createHttpStatement("sa", "d3", "oa3", "good"), createHttpStatement("sb", "d1", "ob1", "good"), createHttpStatement("sb", "d2", "ob2", "good"), createHttpStatement("sb", "d3", "ob3", "bad"), createHttpStatement("sa", "d4", "oa4", "good"), createHttpStatement("sb", "d5", "ob5", "bad")); ConflictResolutionPolicy conflictResolutionPolicy = ConflictResolutionPolicyBuilder.newPolicy() .with(createHttpUri("d1"), resolutionStrategyWithDependsOn(createHttpUri("d3"))) .with(createHttpUri("d2"), resolutionStrategyWithDependsOn(createHttpUri("d3"))) .with(createHttpUri("d4"), resolutionStrategyWithDependsOn(createHttpUri("d5"))) .build(); ResolutionFunction resolutionFunction = MockBestResolutionFunctionWithQuality.newResolutionFunction() .withQuality(createHttpUri("good"), 0.9) .withQuality(createHttpUri("bad"), 0.2); ResourceDescriptionConflictResolver resolver = createResolver(conflictResolutionPolicy, resolutionFunction); Collection<ResolvedStatement> result = resolver.resolveConflicts(new ResourceDescriptionImpl(resource, testInput)); Collection<Statement> expectedStatements = ImmutableList.of( createHttpStatement("sx", "d1", "ob1"), createHttpStatement("sx", "d2", "ob2"), createHttpStatement("sx", "d3", "ob3"), createHttpStatement("sx", "d4", "oa4")); assertThat(result, hasSize(expectedStatements.size())); for (Statement expectedStatement : expectedStatements) { assertThat(result, hasItem(resolvedStatementMatchesStatement(expectedStatement))); } }
@Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); }
ResourceDescriptionConflictResolverImpl implements ResourceDescriptionConflictResolver { @Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); } }
ResourceDescriptionConflictResolverImpl implements ResourceDescriptionConflictResolver { @Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); } ResourceDescriptionConflictResolverImpl(
            ResolutionFunctionRegistry resolutionFunctionRegistry,
            ConflictResolutionPolicy conflictResolutionPolicy,
            UriMapping uriMapping,
            Model metadata,
            String resolvedGraphsURIPrefix, // TODO: replace with UriGenerator class generating uris both for contexts and generated dependent resources
            NestedResourceDescriptionQualityCalculator nestedResourceDescriptionQualityCalculator); }
ResourceDescriptionConflictResolverImpl implements ResourceDescriptionConflictResolver { @Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); } ResourceDescriptionConflictResolverImpl(
            ResolutionFunctionRegistry resolutionFunctionRegistry,
            ConflictResolutionPolicy conflictResolutionPolicy,
            UriMapping uriMapping,
            Model metadata,
            String resolvedGraphsURIPrefix, // TODO: replace with UriGenerator class generating uris both for contexts and generated dependent resources
            NestedResourceDescriptionQualityCalculator nestedResourceDescriptionQualityCalculator); @Override Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription); }
ResourceDescriptionConflictResolverImpl implements ResourceDescriptionConflictResolver { @Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); } ResourceDescriptionConflictResolverImpl(
            ResolutionFunctionRegistry resolutionFunctionRegistry,
            ConflictResolutionPolicy conflictResolutionPolicy,
            UriMapping uriMapping,
            Model metadata,
            String resolvedGraphsURIPrefix, // TODO: replace with UriGenerator class generating uris both for contexts and generated dependent resources
            NestedResourceDescriptionQualityCalculator nestedResourceDescriptionQualityCalculator); @Override Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription); static final ResolutionStrategy DEFAULT_RESOLUTION_STRATEGY; static final String DEFAULT_RESOLVED_GRAPHS_URI_PREFIX; }