test_class.file: tool/hash/src/test/java/org/openscience/cdk/hash/BasicMoleculeHashGeneratorTest.java
test_class.identifier: BasicMoleculeHashGeneratorTest
test_case.body: @Test
      public void testGenerate() {
  
          AtomHashGenerator atomGenerator = mock(AtomHashGenerator.class);
          Pseudorandom prng = mock(Pseudorandom.class);
          IAtomContainer container = mock(IAtomContainer.class);
  
          MoleculeHashGenerator generator = new BasicMoleculeHashGenerator(atomGenerator, prng);
  
          when(atomGenerator.generate(container)).thenReturn(new long[]{1, 1, 1, 1});
          when(prng.next(1L)).thenReturn(1L);
  
          long hashCode = generator.generate(container);
  
          verify(atomGenerator, times(1)).generate(container);
          verify(prng, times(3)).next(1L);
  
          verifyNoMoreInteractions(atomGenerator, container, prng);
  
          long expected = 2147483647L ^ 1L ^ 1L ^ 1L ^ 1L;
  
          assertThat(hashCode, is(expected));
  
      }
test_case.class_method_signature: BasicMoleculeHashGeneratorTest.testGenerate()
test_case.full_signature: @Test public void testGenerate()
test_case.identifier: testGenerate
test_case.invocations: mock mock mock thenReturn when generate thenReturn when next generate generate verify times next verify times verifyNoMoreInteractions assertThat is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGenerate()
focal_class.declarator: generator
focal_class.modifier: private final
focal_class.original_string: private final AtomHashGenerator generator;
focal_class.type: AtomHashGenerator
focal_class.var_name: generator
focal_class.declarator: pseudorandom
focal_class.modifier: private final
focal_class.original_string: private final Pseudorandom      pseudorandom;
focal_class.type: Pseudorandom
focal_class.var_name: pseudorandom
focal_class.file: tool/hash/src/main/java/org/openscience/cdk/hash/BasicMoleculeHashGenerator.java
focal_class.identifier: BasicMoleculeHashGenerator
focal_class.interfaces: implements MoleculeHashGenerator
focal_class.class_method_signature: BasicMoleculeHashGenerator.BasicMoleculeHashGenerator(AtomHashGenerator generator)
focal_class.full_signature: public  BasicMoleculeHashGenerator(AtomHashGenerator generator)
focal_class.identifier: BasicMoleculeHashGenerator
focal_class.modifiers: public
focal_class.parameters: (AtomHashGenerator generator)
focal_class.signature:  BasicMoleculeHashGenerator(AtomHashGenerator generator)
focal_class.class_method_signature: BasicMoleculeHashGenerator.BasicMoleculeHashGenerator(AtomHashGenerator generator, Pseudorandom pseudorandom)
focal_class.full_signature:   BasicMoleculeHashGenerator(AtomHashGenerator generator, Pseudorandom pseudorandom)
focal_class.identifier: BasicMoleculeHashGenerator
focal_class.parameters: (AtomHashGenerator generator, Pseudorandom pseudorandom)
focal_class.signature:  BasicMoleculeHashGenerator(AtomHashGenerator generator, Pseudorandom pseudorandom)
focal_class.class_method_signature: BasicMoleculeHashGenerator.generate(IAtomContainer container)
focal_class.full_signature: @Override public long generate(IAtomContainer container)
focal_class.identifier: generate
focal_class.modifiers: @Override public
focal_class.parameters: (IAtomContainer container)
focal_class.return: long
focal_class.signature: long generate(IAtomContainer container)
focal_method.body: @Override
      public long generate(IAtomContainer container) {
  
          long[] hashes = generator.generate(container);
          long[] rotated = new long[hashes.length];
  
          Arrays.sort(hashes);
  
          // seed with Mersenne prime 2^31-1
          long hash = 2147483647L;
  
          for (int i = 0; i < hashes.length; i++) {
  
              // if non-unique, then get the next random number
              if (i > 0 && hashes[i] == hashes[i - 1]) {
                  hash ^= rotated[i] = pseudorandom.next(rotated[i - 1]);
              } else {
                  hash ^= rotated[i] = hashes[i];
              }
          }
  
          return hash;
      }
focal_method.class_method_signature: BasicMoleculeHashGenerator.generate(IAtomContainer container)
focal_method.full_signature: @Override public long generate(IAtomContainer container)
focal_method.identifier: generate
focal_method.invocations: generate sort next
focal_method.modifiers: @Override public
focal_method.parameters: (IAtomContainer container)
focal_method.return: long
focal_method.signature: long generate(IAtomContainer container)