@Test public void shouldCreateASimpleJaxbWithJaxContextCreateWithGivenClassToBeBound() throws Exception { Class<?>[] classesToBeBound = new Class<?>[0]; SimpleJaxb mockSimpleJaxb = mock(SimpleJaxb.class); mockStatic(JAXBContext.class); when(JAXBContext.newInstance(classesToBeBound)).thenReturn(mockJaxbContext); whenNew(SimpleJaxb.class).withArguments(any(JAXBContext.class)).thenReturn(mockSimpleJaxb); Jaxb actual = JaxbFactory.create(mockCRestConfig, getClass(), classesToBeBound); assertTrue(actual instanceof SimpleJaxb); verifyNew(SimpleJaxb.class).withArguments(mockJaxbContext); }
static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); }
JaxbFactory { static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); } }
JaxbFactory { static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); } private  JaxbFactory(); }
JaxbFactory { static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); } private  JaxbFactory();  }
JaxbFactory { static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); } private  JaxbFactory();   }