use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.
the class ReportSourceTagHandlerTest method testSourceAddDescription.
@Test
public void testSourceAddDescription() {
ReportSourceTag sourceTag = new ReportSourceTag(SourceOperationType.SOURCE_DESCRIPTION, SourceTagAction.SAVE, "dummy", ImmutableList.of("description"));
EasyMock.expect(mockAgentAPI.setDescription("dummy", "description")).andReturn(Response.ok().build()).once();
EasyMock.replay(mockAgentAPI);
sourceTagHandler.report(sourceTag);
((SenderTaskFactoryImpl) senderTaskFactory).flushNow(handlerKey);
EasyMock.verify(mockAgentAPI);
}
use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.
the class ReportSourceTagHandlerTest method testSourceTagAppend.
@Test
public void testSourceTagAppend() {
ReportSourceTag sourceTag = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.ADD, "dummy", ImmutableList.of("tag1"));
EasyMock.expect(mockAgentAPI.appendTag("dummy", "tag1")).andReturn(Response.ok().build()).once();
EasyMock.replay(mockAgentAPI);
sourceTagHandler.report(sourceTag);
((SenderTaskFactoryImpl) senderTaskFactory).flushNow(handlerKey);
EasyMock.verify(mockAgentAPI);
}
use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.
the class ReportSourceTagHandlerTest method testSourceDeleteDescription.
@Test
public void testSourceDeleteDescription() {
ReportSourceTag sourceTag = new ReportSourceTag(SourceOperationType.SOURCE_DESCRIPTION, SourceTagAction.DELETE, "dummy", ImmutableList.of());
EasyMock.expect(mockAgentAPI.removeDescription("dummy")).andReturn(Response.ok().build()).once();
EasyMock.replay(mockAgentAPI);
sourceTagHandler.report(sourceTag);
((SenderTaskFactoryImpl) senderTaskFactory).flushNow(handlerKey);
EasyMock.verify(mockAgentAPI);
}
use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.
the class ReportSourceTagHandlerTest method testSourceTagsTaskAffinity.
@Test
public void testSourceTagsTaskAffinity() {
ReportSourceTag sourceTag1 = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.SAVE, "dummy", ImmutableList.of("tag1", "tag2"));
ReportSourceTag sourceTag2 = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.SAVE, "dummy", ImmutableList.of("tag2", "tag3"));
ReportSourceTag sourceTag3 = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.SAVE, "dummy-2", ImmutableList.of("tag3"));
ReportSourceTag sourceTag4 = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.SAVE, "dummy", ImmutableList.of("tag1", "tag4", "tag5"));
List<SenderTask<SourceTag>> tasks = new ArrayList<>();
SourceTagSenderTask task1 = EasyMock.createMock(SourceTagSenderTask.class);
SourceTagSenderTask task2 = EasyMock.createMock(SourceTagSenderTask.class);
tasks.add(task1);
tasks.add(task2);
ReportSourceTagHandlerImpl sourceTagHandler = new ReportSourceTagHandlerImpl(HandlerKey.of(ReportableEntityType.SOURCE_TAG, "4878"), 10, tasks, null, blockedLogger);
task1.add(new SourceTag(sourceTag1));
EasyMock.expectLastCall();
task1.add(new SourceTag(sourceTag2));
EasyMock.expectLastCall();
task2.add(new SourceTag(sourceTag3));
EasyMock.expectLastCall();
task1.add(new SourceTag(sourceTag4));
EasyMock.expectLastCall();
task1.add(new SourceTag(sourceTag4));
EasyMock.expectLastCall();
task2.add(new SourceTag(sourceTag3));
EasyMock.expectLastCall();
task1.add(new SourceTag(sourceTag2));
EasyMock.expectLastCall();
task1.add(new SourceTag(sourceTag1));
EasyMock.expectLastCall();
EasyMock.replay(task1);
EasyMock.replay(task2);
sourceTagHandler.report(sourceTag1);
sourceTagHandler.report(sourceTag2);
sourceTagHandler.report(sourceTag3);
sourceTagHandler.report(sourceTag4);
sourceTagHandler.report(sourceTag4);
sourceTagHandler.report(sourceTag3);
sourceTagHandler.report(sourceTag2);
sourceTagHandler.report(sourceTag1);
EasyMock.verify();
}
use of wavefront.report.ReportSourceTag in project java by wavefrontHQ.
the class SourceTagSubmissionTaskTest method test200.
@Test
public void test200() {
TaskQueue<SourceTagSubmissionTask> queue = createMock(TaskQueue.class);
reset(sourceTagAPI, queue);
ReportSourceTag sourceDescDelete = new ReportSourceTag(SourceOperationType.SOURCE_DESCRIPTION, SourceTagAction.DELETE, "dummy", ImmutableList.of());
ReportSourceTag sourceTagDelete = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.DELETE, "src", ImmutableList.of("tag"));
ReportSourceTag sourceTagAdd = new ReportSourceTag(SourceOperationType.SOURCE_TAG, SourceTagAction.ADD, "src", ImmutableList.of("tag"));
SourceTagSubmissionTask task = new SourceTagSubmissionTask(sourceTagAPI, props, queue, "2878", new SourceTag(sourceDescDelete), System::currentTimeMillis);
SourceTagSubmissionTask task2 = new SourceTagSubmissionTask(sourceTagAPI, props, queue, "2878", new SourceTag(sourceTagDelete), System::currentTimeMillis);
SourceTagSubmissionTask task3 = new SourceTagSubmissionTask(sourceTagAPI, props, queue, "2878", new SourceTag(sourceTagAdd), System::currentTimeMillis);
expect(sourceTagAPI.removeDescription("dummy")).andReturn(Response.status(200).build()).once();
expect(sourceTagAPI.removeTag("src", "tag")).andReturn(Response.status(200).build()).once();
expect(sourceTagAPI.appendTag("src", "tag")).andReturn(Response.status(200).build()).once();
replay(sourceTagAPI, queue);
assertEquals(TaskResult.DELIVERED, task.execute());
assertEquals(TaskResult.DELIVERED, task2.execute());
assertEquals(TaskResult.DELIVERED, task3.execute());
verify(sourceTagAPI, queue);
}
Aggregations