QueryProcessorFactory { public static QueryProcessor createQueryProcessor(Query query, Class<?> instanceClazz) { if (query == null) { return new NullQueryProcessor(); } if (query instanceof CatnapQuery) { return new CatnapQueryProcessor(); } throw new UnsupportedOperationException(String.format("Query type [%s] is not supported", query.getClass().getName())); }  static QueryProcessor createQueryProcessor(Query query, Class<?> instanceClazz);  }
@Test public void createNullQueryProcessor() { QueryProcessor processor = QueryProcessorFactory.createQueryProcessor(null, Object.class); assertTrue(processor instanceof NullQueryProcessor); }
@Test public void createSimpleQueryProcessor() { QueryProcessor processor = QueryProcessorFactory.createQueryProcessor(new CatnapQuery(), Object.class); assertTrue(processor instanceof CatnapQueryProcessor); }
@Test(expected = UnsupportedOperationException.class) public void unknownQueryTypeThrowsException() { QueryProcessorFactory.createQueryProcessor(new MockQuery(), Object.class); }