### Question:
LocationService extends EnvironmentService { public Location getAgentLocation(UUID participantID) { return (Location) this.sharedState.get("util.location", participantID); } @Inject  LocationService(EnvironmentSharedStateAccess sharedState,
			EnvironmentServiceProvider serviceProvider); @Override void registerParticipant(EnvironmentRegistrationRequest req); Location getAgentLocation(UUID participantID); void setAgentLocation(final UUID participantID, final Location l);  }### Answer:
@Test public void testGetAgentLocation() throws CannotSeeAgent, UnavailableServiceException { final Mockery context = new Mockery(); final EnvironmentSharedStateAccess mockEnv = context .mock(EnvironmentSharedStateAccess.class); final EnvironmentServiceProvider mockServiceProvider = context .mock(EnvironmentServiceProvider.class); final HasArea area = context.mock(HasArea.class); final Area a = new Area(1, 1, 1); context.checking(new Expectations() { { allowing(area).getArea(); will(returnValue(a)); } }); final AreaService areaService = new AreaService(mockEnv, area); final UUID validID = Random.randomUUID(); final Location loc = new Location(0, 0); final UUID invalidID = Random.randomUUID(); context.checking(new Expectations() { { allowing(mockEnv).get("util.location", validID); will(returnValue(loc)); allowing(mockEnv).get("util.location", invalidID); will(returnValue(null)); allowing(mockServiceProvider).getEnvironmentService(AreaService.class); will(returnValue(areaService)); } }); final LocationService serviceUnderTest = new LocationService(mockEnv, mockServiceProvider); assertSame(loc, serviceUnderTest.getAgentLocation(validID)); assertNull(serviceUnderTest.getAgentLocation(invalidID)); context.assertIsSatisfied(); }