Created
July 13, 2012 13:01
-
-
Save jkremser/3104772 to your computer and use it in GitHub Desktop.
Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testFindLiveDataForGroup() throws Exception { | |
Set<MeasurementData> result1 = new HashSet<MeasurementData>(); | |
Set<MeasurementData> result2 = new HashSet<MeasurementData>(); | |
AgentClient mockedAgent1 = mock(AgentClient.class); | |
AgentClient mockedAgent2 = mock(AgentClient.class); | |
MeasurementAgentService mockedMeasurementService1 = mock(MeasurementAgentService.class); | |
MeasurementAgentService mockedMeasurementService2 = mock(MeasurementAgentService.class); | |
AgentManagerLocal mockedAgentManager = mock(AgentManagerLocal.class); | |
when(mockedMeasurementService1.getRealTimeMeasurementValue(1, any(Set.class))).thenReturn(result1); | |
when(mockedMeasurementService2.getRealTimeMeasurementValue(2, null)).thenReturn(result2); | |
when(mockedAgent1.getMeasurementAgentService()).thenReturn(mockedMeasurementService1); | |
when(mockedAgent2.getMeasurementAgentService()).thenReturn(mockedMeasurementService2); | |
when(mockedAgentManager.getAgentClient(eq(agent1))).thenReturn(mockedAgent1); | |
when(mockedAgentManager.getAgentClient(eq(agent2))).thenReturn(mockedAgent2); | |
if (measurementDataManager instanceof MeasurementDataManagerBean) { | |
// measurementDataManager.getClass().getDeclaredField("agentClientManager").set(obj, mockedAgentManager) | |
} | |
try { | |
// do the testing | |
// measurementDataManager.findLiveDataForGroup(subject, groupId, resourceId, definitionIds) | |
} catch (Exception e) { | |
e.printStackTrace(); | |
throw e; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment