DetectorFactory { public Detector buildDetector(DetectorDocument document) { notNull(document, "document can't be null"); val type = document.getType(); val factory = providers.get(type); if (factory == null) { throw new DetectorException("Illegal detector type: " + type); } return factory.buildDetector(document); } DetectorFactory(); Detector buildDetector(DetectorDocument document);  }
@Test(expected = IllegalArgumentException.class) public void testBuildDetector_nullDocument() { factoryUnderTest.buildDetector(null); }
@Test(expected = DetectorException.class) public void testBuildDetector_illegalType() { val document = readDocument("invalid-type"); factoryUnderTest.buildDetector(document); }