use of javax.enterprise.inject.Instance in project ART-TIME by Artezio.
the class TrackingSystemProducerTest method getTrackingSystemsNames.
@Test
public void getTrackingSystemsNames() {
Instance instance = createMock(Instance.class);
trackingSystemProducer = createMockBuilder(TrackingSystemProducer.class).createMock();
TrackingSystem impl1 = createMock(TrackingSystem.class);
TrackingSystem impl2 = createMock(TrackingSystem.class);
List<TrackingSystem> implementations = Arrays.asList(impl1, impl2);
expect(instance.spliterator()).andReturn(implementations.spliterator());
expect(impl1.getName()).andReturn("Impl1");
expect(impl2.getName()).andReturn("Impl2");
replayAll(trackingSystemProducer, instance, impl1, impl2);
Set<String> actual = trackingSystemProducer.getTrackingSystemsNames(instance);
PowerMock.verifyAll();
assertTrue(actual.contains("Impl1"));
assertTrue(actual.contains("Impl2"));
}
use of javax.enterprise.inject.Instance in project ART-TIME by Artezio.
the class TrackingSystemProducerTest method testGetEmployeeTrackingSystem.
@Test
public void testGetEmployeeTrackingSystem() throws NoSuchFieldException {
Settings settings = createMock(Settings.class);
Instance instance = createMock(Instance.class);
trackingSystemProducer = createMockBuilder(TrackingSystemProducer.class).addMockedMethod("findImplementationByName", Instance.class, String.class).createMock();
setField(trackingSystemProducer, "employeeTrackingSystems", instance);
setField(trackingSystemProducer, "settings", settings);
EmployeeTrackingSystem expectedImpl = createMock(EmployeeTrackingSystem.class);
expect(trackingSystemProducer.findImplementationByName(instance, "ExpectedImpl")).andReturn(expectedImpl);
expect(settings.getEmployeeTrackingSystemName()).andReturn("ExpectedImpl");
replayAll(instance, settings, expectedImpl, trackingSystemProducer);
EmployeeTrackingSystem actual = trackingSystemProducer.getEmployeeTrackingSystem();
PowerMock.verifyAll();
assertEquals(expectedImpl, actual);
}
use of javax.enterprise.inject.Instance in project ART-TIME by Artezio.
the class TrackingSystemProducerTest method testFindImplementationByName.
@Test
public void testFindImplementationByName() {
Instance instance = createMock(Instance.class);
trackingSystemProducer = createMockBuilder(TrackingSystemProducer.class).createMock();
TrackingSystem expectedImpl = createMock(TrackingSystem.class);
TrackingSystem unexpectedImpl = createMock(TrackingSystem.class);
List<TrackingSystem> implementations = Arrays.asList(expectedImpl, unexpectedImpl);
expect(instance.iterator()).andReturn(implementations.iterator());
expect(expectedImpl.getName()).andReturn("Expected").anyTimes();
expect(unexpectedImpl.getName()).andReturn("UnExpected").anyTimes();
replayAll(trackingSystemProducer, instance, expectedImpl, unexpectedImpl);
TrackingSystem actual = trackingSystemProducer.findImplementationByName(instance, "Expected");
PowerMock.verifyAll();
assertEquals(expectedImpl, actual);
}
use of javax.enterprise.inject.Instance in project ART-TIME by Artezio.
the class TrackingSystemProducerTest method getDepartmentTrackingSystemNames.
@Test
public void getDepartmentTrackingSystemNames() throws NoSuchFieldException {
Instance instance = createMock(Instance.class);
trackingSystemProducer = createMockBuilder(TrackingSystemProducer.class).addMockedMethod("getTrackingSystemsNames", Instance.class).createMock();
setField(trackingSystemProducer, "departmentTrackingSystems", instance);
Set<String> expected = Sets.newHashSet("A", "B");
expect(trackingSystemProducer.getTrackingSystemsNames(instance)).andReturn(expected);
replayAll(instance, trackingSystemProducer);
Set<String> actual = trackingSystemProducer.getDepartmentTrackingSystemNames();
verifyAll();
assertEquals(expected, actual);
}
use of javax.enterprise.inject.Instance in project wildfly-swarm by wildfly-swarm.
the class ArtifactDeployerTest method stubRuntimeDeployer.
private RuntimeDeployer stubRuntimeDeployer(ArtifactDeployer artifactDeployer) throws NoSuchFieldException, IllegalAccessException {
RuntimeDeployer runtimeDeployer = mock(RuntimeDeployer.class);
Instance runtimeDeployerInstance = mock(Instance.class);
when(runtimeDeployerInstance.get()).thenReturn(runtimeDeployer);
Field deployer = ArtifactDeployer.class.getDeclaredField("deployer");
deployer.setAccessible(true);
deployer.set(artifactDeployer, runtimeDeployerInstance);
return runtimeDeployer;
}
Aggregations