@Test public void testCompoundKeys() throws IOException { HollowCombiner combiner = new HollowCombiner(input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key", "c.key")); combiner.combine(); HollowReadStateEngine output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); assertObject(output, 1, 1, 1, 1, 1, 1); assertObject(output, 2, 1, 2, 1, 2, 1); assertObject(output, 3, 1, 3, 1, 3, 1); assertObject(output, 4, 2, 2, 2, 3, 2); assertObject(output, 5, 2, 4, 2, 4, 2); assertObject(output, 6, 2, 6, 2, 6, 2); assertObject(output, 7, 3, 2, 2, 3, 2); assertObject(output, 8, 3, 7, 3, 6, 3); assertObject(output, 9, 3, 8, 3, 8, 3); assertObject(output, 10,3, 4, 3, 10,3); }
@Before public void setUp() throws IOException { HollowWriteStateEngine input = new HollowWriteStateEngine(); HollowObjectMapper mapper = new HollowObjectMapper(input); addObject(mapper, 1, 1, 1, 1); addObject(mapper, 1, 2, 2, 2); addObject(mapper, 1, 3, 3, 3); input1 = StateEngineRoundTripper.roundTripSnapshot(input); input = new HollowWriteStateEngine(); mapper = new HollowObjectMapper(input); addObject(mapper, 2, 4, 2, 3); addObject(mapper, 2, 5, 4, 4); addObject(mapper, 2, 6, 6, 6); input2 = StateEngineRoundTripper.roundTripSnapshot(input); input = new HollowWriteStateEngine(); mapper = new HollowObjectMapper(input); addObject(mapper, 3, 7, 2, 3); addObject(mapper, 3, 8, 7, 6); addObject(mapper, 3, 9, 8, 8); addObject(mapper, 3, 10, 4, 10); mapper.add(new TypeC(100, 3)); input3 = StateEngineRoundTripper.roundTripSnapshot(input); }
@Test public void testCascadingKeys() throws IOException { HollowCombiner combiner = new HollowCombiner(input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key"), new PrimaryKey("TypeC", "key")); combiner.combine(); HollowReadStateEngine output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); assertObject(output, 1, 1, 1, 1, 1, 1); assertObject(output, 2, 1, 2, 1, 2, 1); assertObject(output, 3, 1, 3, 1, 3, 1); assertObject(output, 4, 2, 2, 1, 2, 1); assertObject(output, 5, 2, 4, 2, 4, 2); assertObject(output, 6, 2, 6, 2, 6, 2); assertObject(output, 7, 3, 2, 1, 2, 1); assertObject(output, 8, 3, 7, 3, 6, 2); assertObject(output, 9, 3, 8, 3, 8, 3); assertObject(output, 10,3, 4, 2, 4, 2); }
@Test public void testCompoundCascadingKeys() throws IOException { HollowCombiner combiner = new HollowCombiner(input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key", "c.key"), new PrimaryKey("TypeC", "key")); combiner.combine(); HollowReadStateEngine output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); assertObject(output, 1, 1, 1, 1, 1, 1); assertObject(output, 2, 1, 2, 1, 2, 1); assertObject(output, 3, 1, 3, 1, 3, 1); assertObject(output, 4, 2, 2, 2, 3, 1); assertObject(output, 5, 2, 4, 2, 4, 2); assertObject(output, 6, 2, 6, 2, 6, 2); assertObject(output, 7, 3, 2, 2, 3, 1); assertObject(output, 8, 3, 7, 3, 6, 2); assertObject(output, 9, 3, 8, 3, 8, 3); assertObject(output, 10,3, 4, 3, 10,3); }
@Test public void testExplicitlyExcludedAndRemappedKeys() throws IOException { HollowPrimaryKeyIndex cIdx1 = new HollowPrimaryKeyIndex(input1, "TypeC", "key"); HollowCombinerExcludePrimaryKeysCopyDirector director = new HollowCombinerExcludePrimaryKeysCopyDirector(); director.excludeKey(cIdx1, 3); HollowCombiner combiner = new HollowCombiner(director, input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key", "c.key"), new PrimaryKey("TypeC", "key")); combiner.combine(); HollowReadStateEngine output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); assertObject(output, 1, 1, 1, 1, 1, 1); assertObject(output, 2, 1, 2, 1, 2, 1); assertObject(output, 3, 1, 3, 1, 3, 2); assertObject(output, 4, 2, 2, 2, 3, 2); assertObject(output, 5, 2, 4, 2, 4, 2); assertObject(output, 6, 2, 6, 2, 6, 2); assertObject(output, 7, 3, 2, 2, 3, 2); assertObject(output, 8, 3, 7, 3, 6, 2); assertObject(output, 9, 3, 8, 3, 8, 3); assertObject(output, 10,3, 4, 3, 10,3); }
@Test public void testExplicitlyExcludedButOtherwiseReferencedKeys() throws IOException { HollowPrimaryKeyIndex cIdx3 = new HollowPrimaryKeyIndex(input3, "TypeC", "key"); HollowCombinerExcludePrimaryKeysCopyDirector director = new HollowCombinerExcludePrimaryKeysCopyDirector(); director.excludeKey(cIdx3, 8); HollowCombiner combiner = new HollowCombiner(director, input1, input2, input3); combiner.setPrimaryKeys(new PrimaryKey("TypeB", "key", "c.key"), new PrimaryKey("TypeC", "key")); combiner.combine(); HollowReadStateEngine output = StateEngineRoundTripper.roundTripSnapshot(combiner.getCombinedStateEngine()); assertObject(output, 9, 3, 8, 3, 8, 3); }