|
|
|
|
@ -273,30 +273,20 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
assertThat(transactionMapper.selectList(null).get(0).getId()).isEqualTo(stepFiveRecordId);
|
|
|
|
|
mvc.perform(post(QUOTA_BASE_PATH + "/steps/package").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6))
|
|
|
|
|
.andExpect(jsonPath("$.data.quotaRequestId").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.amount").value(1589.85))
|
|
|
|
|
.andExpect(jsonPath("$.data.orgId").value("ORG_3A4B5C6D7E8F"))
|
|
|
|
|
.andExpect(jsonPath("$.data.txnId").value(org.hamcrest.Matchers.startsWith("TXN_")))
|
|
|
|
|
.andExpect(jsonPath("$.data.digest").value(org.hamcrest.Matchers.matchesPattern("[0-9A-F]{64}")))
|
|
|
|
|
.andExpect(jsonPath("$.data.signature").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").doesNotExist())
|
|
|
|
|
.andExpect(jsonPath("$.data.quotaRequestMessage").doesNotExist());
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.message").value(org.hamcrest.Matchers.allOf(
|
|
|
|
|
org.hamcrest.Matchers.containsString("\"quotaRequestId\""),
|
|
|
|
|
org.hamcrest.Matchers.containsString("\"amount\":1589.85"),
|
|
|
|
|
org.hamcrest.Matchers.containsString("\"orgId\":\"ORG_3A4B5C6D7E8F\""),
|
|
|
|
|
org.hamcrest.Matchers.containsString("\"txnId\":\"TXN_"))));
|
|
|
|
|
mvc.perform(get(CENTRAL_QUOTA_REQUEST_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(7));
|
|
|
|
|
mvc.perform(post(QUOTA_BASE_PATH + "/steps/send").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6))
|
|
|
|
|
.andExpect(jsonPath("$.data.quotaRequestId").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.amount").value(1589.85))
|
|
|
|
|
.andExpect(jsonPath("$.data.orgId").value("ORG_3A4B5C6D7E8F"))
|
|
|
|
|
.andExpect(jsonPath("$.data.txnId").value(org.hamcrest.Matchers.startsWith("TXN_")))
|
|
|
|
|
.andExpect(jsonPath("$.data.digest").value(org.hamcrest.Matchers.matchesPattern("[0-9A-F]{64}")))
|
|
|
|
|
.andExpect(jsonPath("$.data.signature").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").doesNotExist())
|
|
|
|
|
.andExpect(jsonPath("$.data.centralBankReceiveStatus").doesNotExist());
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("SENT"));
|
|
|
|
|
mvc.perform(get(QUOTA_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6));
|
|
|
|
|
@ -469,8 +459,8 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1));
|
|
|
|
|
mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/package").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("PACKAGED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.responseMessage").value(org.hamcrest.Matchers.containsString(
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.message").value(org.hamcrest.Matchers.containsString(
|
|
|
|
|
"\"cbCtrlSignature\"")));
|
|
|
|
|
mvc.perform(get(COMMERCIAL_BANK_CONTROL_SIGNATURE_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
@ -584,12 +574,10 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").doesNotExist())
|
|
|
|
|
.andExpect(jsonPath("$.data.completeControlBit").doesNotExist());
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/assemble").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.completeControlBit").value(org.hamcrest.Matchers.allOf(
|
|
|
|
|
org.hamcrest.Matchers.containsString("|DYN_"),
|
|
|
|
|
org.hamcrest.Matchers.containsString("|CB_CTRL_"))));
|
|
|
|
|
String completeControlBit = quotaControlBitMapper.selectList(null).get(0).getCompleteControlBit();
|
|
|
|
|
QuotaControlBitEntity beforeSign = quotaControlBitMapper.selectList(null).get(0);
|
|
|
|
|
assertThat(beforeSign.getCompleteControlBit()).isNull();
|
|
|
|
|
String completeControlBit = beforeSign.getStaticSegment() + "|" + beforeSign.getDynamicSegment() + "|"
|
|
|
|
|
+ beforeSign.getCentralBankSignatureSegment();
|
|
|
|
|
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
@ -603,7 +591,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
+ completeControlBit + "_TAMPERED\",\"hashAlgorithm\":\"SM2\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.allOf(
|
|
|
|
|
org.hamcrest.Matchers.containsString("完整额度控制位与步骤八拼接结果不一致"),
|
|
|
|
|
org.hamcrest.Matchers.containsString("完整额度控制位与静态段、动态段及央行签名段拼接结果不一致"),
|
|
|
|
|
org.hamcrest.Matchers.containsString("第5次错误"))));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
@ -618,9 +606,11 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.signature").value(org.hamcrest.Matchers.matchesPattern("[0-9A-F]+")))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1));
|
|
|
|
|
assertThat(quotaControlBitMapper.selectList(null).get(0).getCompleteControlBit())
|
|
|
|
|
.isEqualTo(completeControlBit);
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/package").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("PACKAGED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.requestMessage").value(org.hamcrest.Matchers.containsString("\"quotaId\"")));
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.message").value(org.hamcrest.Matchers.containsString("\"quotaId\"")));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/static-segment")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
@ -649,8 +639,8 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/package").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/send").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("RECEIVED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.receiveStatus").value(2));
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("RECEIVED"));
|
|
|
|
|
mvc.perform(get(CENTRAL_QUOTA_CONTROL_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(2))
|
|
|
|
|
@ -684,15 +674,9 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
flowsUserInputThroughCompleteStepEightAndAccumulatesErrors();
|
|
|
|
|
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/decompose")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"amount\":1590.85}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第7次错误")));
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/decompose")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"amount\":1589.85}"))
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("DECOMPOSED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(2))
|
|
|
|
|
.andExpect(jsonPath("$.data.totalCount").value(27))
|
|
|
|
|
.andExpect(jsonPath("$.data.breakdown[0].denomination").value(100.0))
|
|
|
|
|
.andExpect(jsonPath("$.data.breakdown[0].count").value(15))
|
|
|
|
|
@ -703,7 +687,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.content("{\"prefix\":\"RMB\",\"idRule\":\"批次号+枚序号+随机校验码\"," +
|
|
|
|
|
"\"currencyStatus\":\"待生效\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第8次错误")));
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第7次错误")));
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/confirm-rule")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"prefix\":\"DC\",\"idRule\":\"批次号+枚序号+随机校验码\"," +
|
|
|
|
|
@ -712,16 +696,23 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/generate")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(2))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("GENERATED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies.length()").value(27))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies[0].sequenceNumber").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies[0].denomination").value(100.0))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies[0].currencyId").value(
|
|
|
|
|
.andExpect(jsonPath("$.data.totalCount").value(27))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies").doesNotExist());
|
|
|
|
|
mvc.perform(get(STANDARD_CURRENCY_BASE_PATH + "/currencies")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(27))
|
|
|
|
|
.andExpect(jsonPath("$.data[0].sequenceNumber").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data[0].denomination").value(100.0))
|
|
|
|
|
.andExpect(jsonPath("$.data[0].currencyId").value(
|
|
|
|
|
org.hamcrest.Matchers.matchesPattern("DC_[0-9]{8}_[0-9]{3}_001_[0-9A-Z]{6}")))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies[0].completeCurrency").value(
|
|
|
|
|
.andExpect(jsonPath("$.data[0].completeCurrency").value(
|
|
|
|
|
org.hamcrest.Matchers.containsString("_ORG_3A4B5C6D7E8F_100.00_")))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies[26].denomination").value(0.05))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies[26].status").value("待生效"));
|
|
|
|
|
.andExpect(jsonPath("$.data[0].status").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data[0].randomCheckCode").doesNotExist())
|
|
|
|
|
.andExpect(jsonPath("$.data[0].institutionIdentifier").doesNotExist());
|
|
|
|
|
|
|
|
|
|
List<StandardCurrencyEntity> currencies = standardCurrencyMapper.selectList(null);
|
|
|
|
|
assertThat(standardCurrencyBatchMapper.selectList(null)).hasSize(1);
|
|
|
|
|
@ -729,13 +720,25 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
assertThat(currencies.stream().map(StandardCurrencyEntity::getDenomination)
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)).isEqualByComparingTo("1589.85");
|
|
|
|
|
assertThat(currencies.stream().map(StandardCurrencyEntity::getCurrencyId).distinct().count()).isEqualTo(27);
|
|
|
|
|
StandardCurrencyEntity activated = currencies.get(0);
|
|
|
|
|
activated.setStatus("可用");
|
|
|
|
|
standardCurrencyMapper.updateById(activated);
|
|
|
|
|
mvc.perform(get(STANDARD_CURRENCY_BASE_PATH + "/currencies")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(27))
|
|
|
|
|
.andExpect(jsonPath("$.data[0].status").value(2))
|
|
|
|
|
.andExpect(jsonPath("$.data[1].status").value(1));
|
|
|
|
|
activated.setStatus("待生效");
|
|
|
|
|
standardCurrencyMapper.updateById(activated);
|
|
|
|
|
List<Long> currencyIds = currencies.stream().map(StandardCurrencyEntity::getId)
|
|
|
|
|
.collect(java.util.stream.Collectors.toList());
|
|
|
|
|
long batchId = standardCurrencyBatchMapper.selectList(null).get(0).getId();
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/generate").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("GENERATED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies.length()").value(27));
|
|
|
|
|
.andExpect(jsonPath("$.data.totalCount").value(27))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies").doesNotExist());
|
|
|
|
|
assertThat(standardCurrencyBatchMapper.selectList(null)).hasSize(1);
|
|
|
|
|
assertThat(standardCurrencyBatchMapper.selectList(null).get(0).getId()).isEqualTo(batchId);
|
|
|
|
|
assertThat(standardCurrencyMapper.selectList(null)).hasSize(27);
|
|
|
|
|
@ -746,8 +749,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
@Test
|
|
|
|
|
void rejectsStepNineUntilStepEightIsReceived() throws Exception {
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/decompose")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"amount\":1589.85}"))
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString(
|
|
|
|
|
"步骤八尚未完成央行接收")));
|
|
|
|
|
|