### Question:
AbstractEnvironment implements EnvironmentConnector,
		EnvironmentServiceProvider, TimeDriven { @SuppressWarnings("unchecked") @Override public <T extends EnvironmentService> T getEnvironmentService(Class<T> type) throws UnavailableServiceException { type.toString(); for (EnvironmentService s : this.globalEnvironmentServices) { if (type.isInstance(s)) { return (T) s; } } throw new UnavailableServiceException(type); } @Inject  AbstractEnvironment(SharedStateStorage sharedState); @Inject(optional = true) void deferActions(@DeferActions boolean defer); @Inject(optional = true) void registerTimeDriven(Scenario s); @SuppressWarnings("unchecked") @Override T getEnvironmentService(Class<T> type); @Override synchronized EnvironmentRegistrationResponse register(
			EnvironmentRegistrationRequest request); @Override void act(Action action, UUID actor, UUID authkey); @Override void deregister(UUID participantID, UUID authkey); @Override void incrementTime();  }### Answer:
@Test public void testHasEnvironmentMembersService() throws UnavailableServiceException { final TestAbstractEnvironment envUnderTest = new TestAbstractEnvironment(mockStorage); final EnvironmentService envService = envUnderTest .getEnvironmentService(EnvironmentMembersService.class); assertNotNull(envService); assertTrue(envService instanceof EnvironmentMembersService); }
@Test public void testGetEnvironmentServiceFailure() { final TestAbstractEnvironment envUnderTest = new TestAbstractEnvironment(mockStorage); try { @SuppressWarnings("unused") final EnvironmentService envService = envUnderTest.getEnvironmentService(null); fail("No exception thrown by AbstractEnvironment.getEnvironmentService(null), NullPointerException expected."); } catch (NullPointerException e) { } catch (UnavailableServiceException e) { fail("UnavailableServiceException exception thrown by AbstractEnvironment.getEnvironmentService(null), NullPointerException expected."); } try { @SuppressWarnings("unused") final EnvironmentService envService = envUnderTest .getEnvironmentService(MockEnvironmentService.class); fail("No exception thrown by AbstractEnvironment.getEnvironmentService(MockEnvironmentService.class), UnavailableServiceException expected."); } catch (UnavailableServiceException e) { } }