CombinedPermutationParity extends PermutationParity { @Override public int parity(long[] current) { return left.parity(current) * right.parity(current); } CombinedPermutationParity(PermutationParity left, PermutationParity right); @Override int parity(long[] current);  }
@Test public void testParity() throws Exception { PermutationParity left = mock(PermutationParity.class); PermutationParity right = mock(PermutationParity.class); PermutationParity parity = new CombinedPermutationParity(left, right); long[] dummy = new long[5]; when(left.parity(dummy)).thenReturn(-1); when(right.parity(dummy)).thenReturn(-1); assertThat(parity.parity(dummy), is(1)); verify(left, times(1)).parity(dummy); verify(right, times(1)).parity(dummy); when(left.parity(dummy)).thenReturn(-1); when(right.parity(dummy)).thenReturn(1); assertThat(parity.parity(dummy), is(-1)); when(left.parity(dummy)).thenReturn(1); when(right.parity(dummy)).thenReturn(-1); assertThat(parity.parity(dummy), is(-1)); when(left.parity(dummy)).thenReturn(1); when(right.parity(dummy)).thenReturn(1); assertThat(parity.parity(dummy), is(1)); when(left.parity(dummy)).thenReturn(0); when(right.parity(dummy)).thenReturn(1); assertThat(parity.parity(dummy), is(0)); when(left.parity(dummy)).thenReturn(1); when(right.parity(dummy)).thenReturn(0); assertThat(parity.parity(dummy), is(0)); when(left.parity(dummy)).thenReturn(0); when(right.parity(dummy)).thenReturn(-1); assertThat(parity.parity(dummy), is(0)); when(left.parity(dummy)).thenReturn(-1); when(right.parity(dummy)).thenReturn(0); assertThat(parity.parity(dummy), is(0)); }