final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets,
// Allocations do not add up to 1
fromCompactAllocationFormat("ruleA|-1:0.5,0:0.5,1:0.0", "-1:0.0,0:0.0,1:0.0")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// verifyAndConsolidate should not throw an error because the 'invalidbuckets' test is not required.
assertEquals(1, matrix.getTests().size());
assertValid("invalid test not required, sum{allocations} < 1.0", matrix, Collections.<String, TestSpecification>emptyMap());
assertEquals("non-required tests should be removed from the matrix", 0, matrix.getTests().size());
}
{
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets,
// Allocations do not add up to 1
fromCompactAllocationFormat("ruleA|-1:0.5,0:0.5,1:0.0", "-1:0.0,0:0.0,1:0.0")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// verifyAndConsolidate should throw an error because the 'invalidbuckets' test is required.
assertEquals(1, matrix.getTests().size());
assertInvalid("bucket allocation sums are unchecked, sum{allocations} < 1.0", matrix, requiredTests);
assertEquals("required tests should not be removed from the matrix", 1, matrix.getTests().size());
}
{
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets,
// Allocations do not add up to 1
fromCompactAllocationFormat("ruleA|-1:0.5,0:0.5,1:0.0", "-1:0.5,0:0.5,1:0.5")));
final TestMatrixArtifact matrix = constructArtifact(tests);
assertEquals(1, matrix.getTests().size());
// verifyAndConsolidate should not throw an error because the 'invalidbuckets' test is not required.
assertValid("invalid test not required, sum{allocations} > 1.0", matrix, Collections.<String, TestSpecification>emptyMap());
assertEquals("non-required tests should be removed from the matrix", 0, matrix.getTests().size());
}
{
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets,
// Allocations do not add up to 1
fromCompactAllocationFormat("ruleA|-1:0.5,0:0.5,1:0.0", "-1:0.5,0:0.5,1:0.5")));
final TestMatrixArtifact matrix = constructArtifact(tests);
assertEquals(1, matrix.getTests().size());
// verifyAndConsolidate should throw an error because the 'testa' test is required.
assertInvalid("bucket allocation sums are unchecked, sum{allocations} > 1.0", matrix, requiredTests);
assertEquals("required tests should not be removed from the matrix", 1, matrix.getTests().size());
}
{
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets,
// Allocations add up to 1.0
fromCompactAllocationFormat("ruleA|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25")));
final TestMatrixArtifact matrix = constructArtifact(tests);
assertEquals(1, matrix.getTests().size());
assertValid("bucket allocation sums are unchecked, sum{allocations} == 1.0", matrix, Collections.<String, TestSpecification>emptyMap());
assertEquals("non-required tests should be removed from the matrix", 0, matrix.getTests().size());
}
{
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets,
// Allocations add up to 1.0
fromCompactAllocationFormat("ruleA|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25")));
final TestMatrixArtifact matrix = constructArtifact(tests);
assertEquals(1, matrix.getTests().size());
assertValid("bucket allocation sums are unchecked, sum{allocations} == 1.0", matrix, requiredTests);
assertEquals("required tests should not be removed from the matrix", 1, matrix.getTests().size());
}
}