SuppressedAtomHashGenerator extends AbstractAtomHashGenerator implements AtomHashGenerator { @Override public long[] generate(IAtomContainer container) { int[][] graph = toAdjList(container); Suppressed suppressed = suppression.suppress(container); return generate(seedGenerator.generate(container), factory.create(container, graph), graph, suppressed); } SuppressedAtomHashGenerator(AtomHashGenerator seedGenerator, Pseudorandom pseudorandom,
            StereoEncoderFactory factory, AtomSuppression suppression, int depth);  SuppressedAtomHashGenerator(AtomHashGenerator seedGenerator, Pseudorandom pseudorandom,
            AtomSuppression suppression, int depth); @Override long[] generate(IAtomContainer container);  }
@Test public void testGenerate() throws Exception { AtomHashGenerator seedMock = mock(AtomHashGenerator.class); IAtomContainer container = mock(IAtomContainer.class); AtomHashGenerator generator = new SuppressedAtomHashGenerator(seedMock, new Xorshift(), AtomSuppression.unsuppressed(), 0); when(seedMock.generate(container)).thenReturn(new long[0]); when(container.bonds()).thenReturn(new Iterable<IBond>() { @Override public Iterator<IBond> iterator() { return new Iterator<IBond>() { @Override public boolean hasNext() { return false; } @Override public IBond next() { return null; } @Override public void remove() { } }; } }); generator.generate(container); verify(seedMock, times(1)).generate(container); }
@Test public void testGenerate_ZeroDepth() throws Exception { AtomHashGenerator seedMock = mock(AtomHashGenerator.class); IAtomContainer container = mock(IAtomContainer.class); SuppressedAtomHashGenerator generator = new SuppressedAtomHashGenerator(mock(AtomHashGenerator.class), new Xorshift(), AtomSuppression.unsuppressed(), 0); assertThat( generator.generate(new long[]{1L, 1L, 1L}, StereoEncoder.EMPTY, new int[][]{{}, {}, {}}, Suppressed.none()), is(new long[]{1L, 1L, 1L})); BitSet suppressed = new BitSet(); suppressed.set(0); suppressed.set(2); assertThat( generator.generate(new long[]{1L, 1L, 1L}, StereoEncoder.EMPTY, new int[][]{{}, {}, {}}, Suppressed.fromBitSet(suppressed)), is(new long[]{0L, 1L, 0L})); }
@Test public void testGenerate_Disconnected() throws Exception { AtomHashGenerator seedMock = mock(AtomHashGenerator.class); IAtomContainer container = mock(IAtomContainer.class); SuppressedAtomHashGenerator generator = new SuppressedAtomHashGenerator(mock(AtomHashGenerator.class), new Xorshift(), AtomSuppression.unsuppressed(), 2); long expected = generator.distribute(generator.distribute(1)); assertThat( generator.generate(new long[]{1L, 1L, 1L}, StereoEncoder.EMPTY, new int[][]{{}, {}, {}}, Suppressed.none()), is(new long[]{expected, expected, expected})); BitSet suppressed = new BitSet(); suppressed.set(1); assertThat( generator.generate(new long[]{1L, 1L, 1L}, StereoEncoder.EMPTY, new int[][]{{}, {}, {}}, Suppressed.fromBitSet(suppressed)), is(new long[]{expected, 0L, expected})); }
@Test public void testGenerate_Simple() throws Exception { AtomHashGenerator seedMock = mock(AtomHashGenerator.class); IAtomContainer container = mock(IAtomContainer.class); SuppressedAtomHashGenerator generator = new SuppressedAtomHashGenerator(mock(AtomHashGenerator.class), new Xorshift(), AtomSuppression.unsuppressed(), 2); { long[] first = new long[]{generator.distribute(1) ^ 2L, generator.distribute(2L) ^ 1L ^ generator.rotate(1L), generator.distribute(1) ^ 2L}; long[] second = new long[]{generator.distribute(first[0]) ^ first[1], generator.distribute(first[1]) ^ first[0] ^ generator.rotate(first[2]), generator.distribute(first[2]) ^ first[1]}; assertThat(generator.generate(new long[]{1L, 2L, 1L}, StereoEncoder.EMPTY, new int[][]{{1}, {0, 2}, {1}}, Suppressed.none()), is(second)); } BitSet suppressed = new BitSet(); suppressed.set(2); { long[] first = new long[]{generator.distribute(1) ^ 2L, generator.distribute(2L) ^ 1L, 0L,}; long[] second = new long[]{generator.distribute(first[0]) ^ first[1], generator.distribute(first[1]) ^ first[0], 0L}; assertThat(generator.generate(new long[]{1L, 2L, 1L}, StereoEncoder.EMPTY, new int[][]{{1}, {0, 2}, {1}}, Suppressed.fromBitSet(suppressed)), is(second)); } }