PairedEndFastqReader { public static void streamPaired(final Reader firstReader, final Reader secondReader, final PairedEndListener listener) throws IOException { streamPaired((Readable) firstReader, (Readable) secondReader, listener); } private  PairedEndFastqReader(); static void readPaired(final Reader firstReader,
                                  final Reader secondReader,
                                  final PairedEndListener listener); static void readPaired(final Readable firstReadable,
                                  final Readable secondReadable,
                                  final PairedEndListener listener); static void streamPaired(final Reader firstReader,
                                    final Reader secondReader,
                                    final PairedEndListener listener); static void streamPaired(final Readable firstReadable,
                                    final Readable secondReadable,
                                    final PairedEndListener listener); static void streamInterleaved(final Reader reader, final PairedEndListener listener); static void streamInterleaved(final Readable readable, final PairedEndListener listener);  }
@Test(expected=NullPointerException.class) public void testStreamPairedNullFirstReader() throws Exception { streamPaired(null, secondReader, listener); }
@Test(expected=NullPointerException.class) public void testStreamPairedNullSecondReader() throws Exception { streamPaired(firstReader, null, listener); }
@Test(expected=NullPointerException.class) public void testStreamPairedNullListener() throws Exception { streamPaired(firstReader, secondReader, null); }
@Test public void testStreamPaired() throws Exception { streamPaired(firstReader, secondReader, new PairedEndAdapter() { @Override public void paired(final Fastq left, final Fastq right) { assertEquals(PairedEndFastqReaderTest.this.left.getDescription(), left.getDescription()); assertEquals(PairedEndFastqReaderTest.this.right.getDescription(), right.getDescription()); } @Override public void unpaired(final Fastq unpaired) { fail("unpaired " + unpaired); } }); }
@Test public void testStreamPairedUnpaired() throws Exception { streamPaired(firstReader, firstReader, new PairedEndAdapter() { @Override public void paired(final Fastq left, final Fastq right) { fail("paired " + left + " " + right); } @Override public void unpaired(final Fastq unpaired) { assertEquals(PairedEndFastqReaderTest.this.left.getDescription(), left.getDescription()); } }); }
@Test(expected=IOException.class) public void testStreamPairedInvalidPrefixLeft() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); new SangerFastqWriter().write(outputStream, invalidPrefix); Reader invalidPrefixReader = new StringReader(outputStream.toString()); streamPaired(invalidPrefixReader, secondReader, listener); }
@Test(expected=IOException.class) public void testStreamPairedInvalidPrefixRight() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); new SangerFastqWriter().write(outputStream, invalidPrefix); Reader invalidPrefixReader = new StringReader(outputStream.toString()); streamPaired(firstReader, invalidPrefixReader, listener); }
@Test public void testStreamPairedMismatchPrefix() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); new SangerFastqWriter().write(outputStream, mismatchPrefix); Reader mismatchPrefixReader = new StringReader(outputStream.toString()); streamPaired(firstReader, mismatchPrefixReader, new PairedEndAdapter() { @Override public void paired(final Fastq left, final Fastq right) { fail("paired " + left + " " + right); } @Override public void unpaired(final Fastq unpaired) { assertTrue(left.getDescription().equals(unpaired.getDescription()) || mismatchPrefix.getDescription().equals(unpaired.getDescription())); } }); }