@Test
public void taintsAndTolerationsDoNotMatch() {

    AgentInstance instance = createAgentInstance(INSTANCE_GROUP_ID, Collections.singletonMap(SchedulerAttributes.TAINTS, "b,d"));
    when(agentManagementService.findAgentInstance(INSTANCE_ID)).thenReturn(Optional.of(instance));
    AgentInstanceGroup agentInstanceGroup = createAgentInstanceGroup(InstanceGroupLifecycleState.Active, Tier.Flex,
            Collections.singletonMap(SchedulerAttributes.TAINTS, "b,c"));
    when(agentManagementService.findInstanceGroup(INSTANCE_GROUP_ID)).thenReturn(Optional.of(agentInstanceGroup));
    JobDescriptor<BatchJobExt> descriptor = oneTaskBatchJobDescriptor()
            .but(jd -> jd.toBuilder().withAttributes(Collections.singletonMap(JOB_PARAMETER_ATTRIBUTES_TOLERATIONS, "a,b")));
    Job<BatchJobExt> job = JobGenerator.batchJobs(descriptor).getValue();
    TaskRequest taskRequest = createTaskRequest(job);
    Result result = agentManagementConstraint.evaluate(taskRequest,
            createVirtualMachineCurrentStateMock(INSTANCE_ID), mock(TaskTrackerState.class));
    assertThat(result.isSuccessful()).isFalse();
    assertThat(result.getFailureReason()).isEqualToIgnoringCase("Cannot place on instance group or agent instance due to toleration attribute not matching taint attribute");
}