@Test public void machineIdDoesMatch() { AgentInstance instance = AgentGenerator.agentInstances().getValue().toBuilder().withId(MACHINE_ID).build(); when(agentManagementService.findAgentInstance(MACHINE_ID)).thenReturn(Optional.of(instance)); Result result = constraint.evaluate(createTaskRequest(TASK_ID), createVirtualMachineCurrentStateMock(MACHINE_ID), createTaskTrackerState()); assertThat(result.isSuccessful()).isTrue(); }
@Override public Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) { Optional<AgentInstance> instanceOpt = SchedulerUtils.findInstance(agentManagementService, configuration.getInstanceAttributeName(), targetVM); if (!instanceOpt.isPresent()) { return MACHINE_DOES_NOT_EXIST; } AgentInstance agentInstance = instanceOpt.get(); return agentInstance.getId().equalsIgnoreCase(machineId) ? VALID : MACHINE_ID_DOES_NOT_MATCH; }
MachineIdConstraint implements ConstraintEvaluator { @Override public Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) { Optional<AgentInstance> instanceOpt = SchedulerUtils.findInstance(agentManagementService, configuration.getInstanceAttributeName(), targetVM); if (!instanceOpt.isPresent()) { return MACHINE_DOES_NOT_EXIST; } AgentInstance agentInstance = instanceOpt.get(); return agentInstance.getId().equalsIgnoreCase(machineId) ? VALID : MACHINE_ID_DOES_NOT_MATCH; } }
MachineIdConstraint implements ConstraintEvaluator { @Override public Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) { Optional<AgentInstance> instanceOpt = SchedulerUtils.findInstance(agentManagementService, configuration.getInstanceAttributeName(), targetVM); if (!instanceOpt.isPresent()) { return MACHINE_DOES_NOT_EXIST; } AgentInstance agentInstance = instanceOpt.get(); return agentInstance.getId().equalsIgnoreCase(machineId) ? VALID : MACHINE_ID_DOES_NOT_MATCH; } MachineIdConstraint(SchedulerConfiguration configuration, AgentManagementService agentManagementService, String machineId); }
MachineIdConstraint implements ConstraintEvaluator { @Override public Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) { Optional<AgentInstance> instanceOpt = SchedulerUtils.findInstance(agentManagementService, configuration.getInstanceAttributeName(), targetVM); if (!instanceOpt.isPresent()) { return MACHINE_DOES_NOT_EXIST; } AgentInstance agentInstance = instanceOpt.get(); return agentInstance.getId().equalsIgnoreCase(machineId) ? VALID : MACHINE_ID_DOES_NOT_MATCH; } MachineIdConstraint(SchedulerConfiguration configuration, AgentManagementService agentManagementService, String machineId); @Override String getName(); @Override Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState); }
MachineIdConstraint implements ConstraintEvaluator { @Override public Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) { Optional<AgentInstance> instanceOpt = SchedulerUtils.findInstance(agentManagementService, configuration.getInstanceAttributeName(), targetVM); if (!instanceOpt.isPresent()) { return MACHINE_DOES_NOT_EXIST; } AgentInstance agentInstance = instanceOpt.get(); return agentInstance.getId().equalsIgnoreCase(machineId) ? VALID : MACHINE_ID_DOES_NOT_MATCH; } MachineIdConstraint(SchedulerConfiguration configuration, AgentManagementService agentManagementService, String machineId); @Override String getName(); @Override Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState); static final String NAME; }