Search in sources :

Example 16 with LRAStatus

use of org.eclipse.microprofile.lra.annotation.LRAStatus in project narayana by jbosstm.

the class LRATest method assertStatus.

private void assertStatus(String lraId, LRAStatus expected, boolean nullValid) {
    try {
        LRAStatus status = getStatus(new URI(lraId));
        assertTrue("unexpected null LRA status", status != null || nullValid);
        assertTrue("Expected status " + expected + " but state was " + status, status == null || status == expected);
    } catch (URISyntaxException e) {
        fail(String.format("%s: %s", testName.getMethodName(), e.getMessage()));
    }
}
Also used : LRAStatus(org.eclipse.microprofile.lra.annotation.LRAStatus) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 17 with LRAStatus

use of org.eclipse.microprofile.lra.annotation.LRAStatus in project narayana by jbosstm.

the class NonRootLRAParticipantIT method testFinishLRA.

/*
     * Test that a participant can join an LRA using the Narayana specific client API
     * Test that the LRA has the correct status of Closing if a participant
     * returns 202 Accepted when asked to complete.
     * @throws URISyntaxException if arquillian URL is invalid
     */
@Test
public void testFinishLRA() throws URISyntaxException {
    URI lraId = lraClient.startLRA("testFinishLRA");
    lrasToAfterFinish.add(lraId);
    URI compensateURI = new URI(baseURL.toExternalForm() + "/participant/compensate");
    URI completeURI = new URI(baseURL.toExternalForm() + "/participant/complete");
    // enlist the participant with these compensate and complete URIs into the LRA
    lraClient.joinLRA(lraId, 0L, compensateURI, completeURI, null, null, null, null, null);
    lraClient.closeLRA(lraId);
    try {
        LRAStatus status = lraClient.getStatus(lraId);
        Assert.assertEquals("wrong state", Closing, status);
    } catch (WebApplicationException e) {
        fail("testFinishLRA: received unexpected response code (" + e.getResponse().getStatus() + ") getting LRA status " + e.getMessage());
    }
}
Also used : LRAStatus(org.eclipse.microprofile.lra.annotation.LRAStatus) WebApplicationException(javax.ws.rs.WebApplicationException) URI(java.net.URI) Test(org.junit.Test)

Aggregations

LRAStatus (org.eclipse.microprofile.lra.annotation.LRAStatus)17 URI (java.net.URI)12 Test (org.junit.Test)6 Path (javax.ws.rs.Path)5 GET (javax.ws.rs.GET)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 Response (javax.ws.rs.core.Response)4 LongRunningAction (io.narayana.lra.coordinator.domain.model.LongRunningAction)3 URISyntaxException (java.net.URISyntaxException)3 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)2 LRAData (io.narayana.lra.LRAData)2 LRAService (io.narayana.lra.coordinator.domain.service.LRAService)2 LRALogger (io.narayana.lra.logging.LRALogger)2 IOException (java.io.IOException)2 DELETE (javax.ws.rs.DELETE)2 NotFoundException (javax.ws.rs.NotFoundException)2 Produces (javax.ws.rs.Produces)2 Client (javax.ws.rs.client.Client)2 Operation (org.eclipse.microprofile.openapi.annotations.Operation)2 APIResponses (org.eclipse.microprofile.openapi.annotations.responses.APIResponses)2