DefaultServiceFactory implements ServiceFactory { @Override public Object create( Class<?> serviceType, String component, RdfSource definition, Component.Context context) throws LpException { if (serviceType.equals(ExceptionFactory.class)) { return new DefaultExceptionFactory(); } if (serviceType.equals(ProgressReport.class)) { return new DefaultProgressReport(context, component); } if (serviceType.equals(DefinitionReader.class)) { return new DefaultDefinitionReader(component, definition); } if (serviceType.equals(WorkingDirectory.class)) { return createWorkingDirectory(component, definition); } throw new LpException("Invalid service type: {}", serviceType.getName()); }  @Override Object create(
            Class<?> serviceType, String component,
            RdfSource definition, Component.Context context);  }
@Test public void exceptionFactory() throws LpException { DefaultServiceFactory factory = new DefaultServiceFactory(); ExceptionFactory result = (ExceptionFactory) factory.create( ExceptionFactory.class, null, null, null); Assert.assertNotNull(result); Assert.assertNotNull(result.failure("Message")); }
@Test public void progressReport() throws LpException { Component.Context context = Mockito.mock(Component.Context.class); DefaultServiceFactory factory = new DefaultServiceFactory(); ProgressReport result = (ProgressReport) factory.create( ProgressReport.class, null, null, context); Assert.assertNotNull(result); result.start(2); result.entryProcessed(); result.entryProcessed(); result.done(); Mockito.verify(context, Mockito.times(4)).sendMessage(Mockito.any()); }