Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets, "longValue", null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertValid("all payloads of the same type", matrix, requiredTests);
}
{
List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setLongValue(-1L);
buckets.get(0).setPayload(p);
// bucket 1 is missing a payload here.
p = new Payload();
p.setLongValue(1L);
buckets.get(2).setPayload(p);
Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets, "longValue", null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertInvalid("not all payloads of the test defined", matrix, requiredTests);
}
{
List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setStringValue("inact");
buckets.get(0).setPayload(p);
p = new Payload();
p.setStringValue("foo");
buckets.get(1).setPayload(p);
p = new Payload();
p.setStringValue("bar");
buckets.get(2).setPayload(p);
Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets, "longValue", null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertInvalid("all payloads of the wrong type", matrix, requiredTests);
}
{
List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setLongValue(-1L);
buckets.get(0).setPayload(p);
p = new Payload();
p.setLongValue(0L);
buckets.get(1).setPayload(p);
p = new Payload();
p.setStringValue("foo");
buckets.get(2).setPayload(p);
Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets, "longValue", null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally inconsistent matrix: different payload types in test
assertInvalid("all payloads not of the same type", matrix, requiredTests);
}
{
List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setStringArray(new String[]{}); // empty arrays are allowed.
buckets.get(0).setPayload(p);
p = new Payload();
p.setStringArray(new String[]{"foo", "bar"});
buckets.get(1).setPayload(p);
p = new Payload();
p.setStringArray(new String[]{"baz", "quux", "xyzzy"});
buckets.get(2).setPayload(p);
Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets, "stringArray", null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertValid("vector payloads can be different lengths", matrix, requiredTests);
}
{
final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",1.0,"val2","one","val3",new ArrayList<String>()));
buckets.get(0).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2","tw","val3",new ArrayList<String>(){{add("a");add("c");}}));
buckets.get(1).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2","th","val3",new ArrayList<String>(){{add("foo");add("bar");}}));
buckets.get(2).setPayload(p);
final Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets,"map",
ImmutableMap.of("val1","doubleValue","val2","stringValue","val3","stringArray"), null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
assertValid("correct allocation and object, map with double values", matrix, requiredTests);
}
{
final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",1.0,"val2",3.0,"val3",1.0));
buckets.get(0).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val3",1.0,"val4",3.0));
buckets.get(1).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2",2.0,"val3",2.0));
buckets.get(2).setPayload(p);
final Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets,"map",
ImmutableMap.of("val1","doubleValue","val2","doubleValue","val3","doubleValue"), null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertInvalid("map payloads can't have different variable names", matrix, requiredTests);
}
{
final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",1.0,"val2","yea1","val3",1.0));
buckets.get(0).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2","yea2","val3",3.0));
buckets.get(1).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2","yea3","val3",2.0));
buckets.get(2).setPayload(p);
final Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets,"map",
ImmutableMap.of("val1","doubleValue","val2","doubleValue","val3","doubleValue"), null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertInvalid("map payloads can't have different variable types than specified", matrix, requiredTests);
}
{
final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",1.0,"val2",3.0,"val3",1.0));
buckets.get(0).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2",1.0,"val3",3.0));
buckets.get(1).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2",2.0,"val3",2.0));
buckets.get(2).setPayload(p);
final Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets,"map",
ImmutableMap.of("val1","doubleValue","val2","doubleValue","val3","doubleValue","val4","doubleArray"), null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertInvalid("map payloads can't have less variable types than specified", matrix, requiredTests);
}
{
final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",1.0,"val2",3.0,"val3",1.0));
buckets.get(0).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2",new ArrayList<Double>(){{add(1.0D);}},"val3",3.0));
buckets.get(1).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2",2.0,"val3",2.0));
buckets.get(2).setPayload(p);
final Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets,"map",
ImmutableMap.of("val1","doubleValue","val2","doubleValue","val3","doubleValue"), null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertInvalid("map payloads can't have different variable types than specified -- an array instead of a single value", matrix, requiredTests);
}
{
final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",1.0,"val2",ImmutableMap.<String,Object>of("a",1,"b",2),"val3",1.0));
buckets.get(0).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2",ImmutableMap.<String,Object>of("c",3,"d",4),"val3",3.0));
buckets.get(1).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2",ImmutableMap.<String,Object>of("e",5,"f",6),"val3",2.0));
buckets.get(2).setPayload(p);
final Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets,"map",
ImmutableMap.of("val1","doubleValue","val2","map","val3","doubleValue"), null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
// internally consistent matrix
assertInvalid("map payloads can't nested map payloads", matrix, requiredTests);
}
{
final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
Payload p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",1.0,"val2","one","val3",new ArrayList<String>()));
buckets.get(0).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2","tw","val3",new ArrayList<String>(){{add("a");add("c");}}));
buckets.get(1).setPayload(p);
p = new Payload();
p.setMap(ImmutableMap.<String,Object>of("val1",2.0,"val2","th","val3",new ArrayList(){{add(2.1D);add("bar");}}));
buckets.get(2).setPayload(p);
final Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets,"map",
ImmutableMap.of("val1","doubleValue","val2","stringValue","val3","stringArray"), null));
final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("-1:0.2,0:0.4,1:0.4")));
final TestMatrixArtifact matrix = constructArtifact(tests);
assertInvalid("map payload nested arrays can't have multiple types", matrix, requiredTests);
}
}