@Test
public void testEventHandlerWithCondition() {

    EventHandler eventHandler = new EventHandler();
    eventHandler.setName("cms_intermediate_video_ingest_handler");
    eventHandler.setActive(true);
    eventHandler.setEvent("sqs:dev_cms_asset_ingest_queue");
    eventHandler.setCondition("$.Message.testKey1 == 'level1' && $.Message.metadata.testKey2 == 123456");
    Map<String, Object> startWorkflowInput = new LinkedHashMap<>();
    startWorkflowInput.put("param1", "${Message.metadata.testKey2}");
    startWorkflowInput.put("param2", "SQS-${MessageId}");
    Action startWorkflowAction = new Action();
    startWorkflowAction.setAction(Type.start_workflow);
    startWorkflowAction.setStart_workflow(new StartWorkflow());
    startWorkflowAction.getStart_workflow().setName("cms_artwork_automation");
    startWorkflowAction.getStart_workflow().setVersion(1);
    startWorkflowAction.getStart_workflow().setInput(startWorkflowInput);
    startWorkflowAction.setExpandInlineJSON(true);
    eventHandler.getActions().add(startWorkflowAction);
    eventHandler.setEvent(event);
    when(metadataService.getAllEventHandlers()).thenReturn(Collections.singletonList(eventHandler));
    when(metadataService.getEventHandlersForEvent(event, true)).thenReturn(Collections.singletonList(eventHandler));
    when(executionService.addEventExecution(any())).thenReturn(true);
    when(queue.rePublishIfNoAck()).thenReturn(false);
    String id = UUID.randomUUID().toString();
    AtomicBoolean started = new AtomicBoolean(false);
    doAnswer((Answer<String>) invocation -> {
        started.set(true);
        return id;
    }).when(workflowExecutor).startWorkflow(eq(startWorkflowAction.getStart_workflow().getName()), eq(startWorkflowAction.getStart_workflow().getVersion()), eq(startWorkflowAction.getStart_workflow().getCorrelationId()), anyMap(), eq(null), eq(event), eq(null));
    WorkflowDef workflowDef = new WorkflowDef();
    workflowDef.setName(startWorkflowAction.getStart_workflow().getName());
    when(metadataService.getWorkflowDef(any(), any())).thenReturn(workflowDef);
    SimpleActionProcessor actionProcessor = new SimpleActionProcessor(workflowExecutor, parametersUtils, jsonUtils);
    SimpleEventProcessor eventProcessor = new SimpleEventProcessor(executionService, metadataService, actionProcessor, eventQueues, jsonUtils, new TestConfiguration(), objectMapper);
    assertNotNull(eventProcessor.getQueues());
    assertEquals(1, eventProcessor.getQueues().size());
    Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
    assertTrue(started.get());
}