Search in sources :

Example 6 with BranchReportRequest

use of io.seata.core.protocol.transaction.BranchReportRequest in project seata by seata.

the class BranchReportRequestConvertor method convert2Model.

@Override
public BranchReportRequest convert2Model(BranchReportRequestProto branchReportRequestProto) {
    BranchReportRequest branchReportRequest = new BranchReportRequest();
    branchReportRequest.setApplicationData(branchReportRequestProto.getApplicationData());
    branchReportRequest.setBranchId(branchReportRequestProto.getBranchId());
    branchReportRequest.setResourceId(branchReportRequestProto.getResourceId());
    branchReportRequest.setXid(branchReportRequestProto.getXid());
    branchReportRequest.setBranchType(BranchType.valueOf(branchReportRequestProto.getBranchType().name()));
    branchReportRequest.setStatus(BranchStatus.valueOf(branchReportRequestProto.getStatus().name()));
    return branchReportRequest;
}
Also used : BranchReportRequest(io.seata.core.protocol.transaction.BranchReportRequest)

Example 7 with BranchReportRequest

use of io.seata.core.protocol.transaction.BranchReportRequest in project seata by seata.

the class BranchReportRequestConvertorTest method convert2Proto.

@Test
public void convert2Proto() {
    BranchReportRequest branchReportRequest = new BranchReportRequest();
    branchReportRequest.setApplicationData("data");
    branchReportRequest.setBranchId(123);
    branchReportRequest.setResourceId("resourceId");
    branchReportRequest.setXid("xid");
    branchReportRequest.setBranchType(BranchType.AT);
    branchReportRequest.setStatus(BranchStatus.PhaseOne_Done);
    BranchReportRequestConvertor convertor = new BranchReportRequestConvertor();
    BranchReportRequestProto proto = convertor.convert2Proto(branchReportRequest);
    BranchReportRequest real = convertor.convert2Model(proto);
    assertThat(real.getBranchType()).isEqualTo(branchReportRequest.getBranchType());
    assertThat(real.getXid()).isEqualTo(branchReportRequest.getXid());
    assertThat(real.getResourceId()).isEqualTo(branchReportRequest.getResourceId());
    assertThat(real.getBranchId()).isEqualTo(branchReportRequest.getBranchId());
    assertThat(real.getApplicationData()).isEqualTo(branchReportRequest.getApplicationData());
    assertThat(real.getStatus()).isEqualTo(branchReportRequest.getStatus());
}
Also used : BranchReportRequestProto(io.seata.serializer.protobuf.generated.BranchReportRequestProto) BranchReportRequest(io.seata.core.protocol.transaction.BranchReportRequest) Test(org.junit.jupiter.api.Test)

Example 8 with BranchReportRequest

use of io.seata.core.protocol.transaction.BranchReportRequest in project seata by seata.

the class BranchReportRequestTest method testToString.

/**
 * Test to string.
 */
@Test
public void testToString() {
    BranchReportRequest branchReportRequest = new BranchReportRequest();
    branchReportRequest.setXid("127.0.0.1:8091:1249853");
    branchReportRequest.setBranchId(3);
    branchReportRequest.setResourceId("resource003");
    branchReportRequest.setStatus(BranchStatus.PhaseOne_Timeout);
    branchReportRequest.setApplicationData("test app data");
    Assertions.assertEquals("xid=127.0.0.1:8091:1249853,branchId=3,resourceId=resource003,status=PhaseOne_Timeout," + "applicationData=test app" + " data", branchReportRequest.toString());
}
Also used : BranchReportRequest(io.seata.core.protocol.transaction.BranchReportRequest) Test(org.junit.jupiter.api.Test)

Aggregations

BranchReportRequest (io.seata.core.protocol.transaction.BranchReportRequest)8 Test (org.junit.jupiter.api.Test)3 BranchReportResponse (io.seata.core.protocol.transaction.BranchReportResponse)2 StoreException (io.seata.common.exception.StoreException)1 RmTransactionException (io.seata.core.exception.RmTransactionException)1 TransactionException (io.seata.core.exception.TransactionException)1 BranchStatus (io.seata.core.model.BranchStatus)1 BranchType (io.seata.core.model.BranchType)1 BranchReportRequestProto (io.seata.serializer.protobuf.generated.BranchReportRequestProto)1 TimeoutException (java.util.concurrent.TimeoutException)1