package cz.moneta.test.system.messaging.imq;

import java.util.concurrent.TimeUnit;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.endpoints.imq.ImqFirstVisionQueue;

@TestScenario(name = "IBM MQ Correlation ID Test")
public class ImqCorrelationIdTest {

	@TestCase(name = "Send message with Correlation ID")
	public void sendMessageWithCorrelationId(Harness harness) {
		harness.withImqFirstVision().toQueue(ImqFirstVisionQueue.PAYMENT_NOTIFICATIONS)
				.withPayload("{\"paymentId\": \"PAY-789\"}").withCorrelationId("corr-789").withMessageId("123456789012345678901234").send();
	}

	@TestCase(name = "Receive message with Correlation ID")
	public void receiveMessageWithCorrelationId(Harness harness) {
		harness.withImqFirstVision().fromQueue(ImqFirstVisionQueue.PAYMENT_NOTIFICATIONS)
				.withSelector("JMSCorrelationID = 'corr-789'").receiveWhere(msg -> true)
				.withTimeout(10, TimeUnit.SECONDS);
	}
}