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;
}
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());
}
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());
}
Aggregations