BJ-782: Throw exception when revision is invalid (#13)

This commit is contained in:
Pavel Popov 2020-02-03 19:28:56 +03:00 committed by GitHub
parent 33250f72b8
commit 137954ba0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -66,7 +66,7 @@ public class ClaimCommitterService {
).run(); ).run();
} catch (InvalidClaimStatusException | InvalidRevisionException ex) { } catch (InvalidClaimStatusException | InvalidRevisionException ex) {
log.warn("Claim has been changed, no commit needed", ex); throw ex;
} }
} }

View File

@ -1,6 +1,7 @@
package com.rbkmoney.cm.service; package com.rbkmoney.cm.service;
import com.rbkmoney.cm.AbstractWithCommittersIntegrationTest; import com.rbkmoney.cm.AbstractWithCommittersIntegrationTest;
import com.rbkmoney.cm.exception.InvalidRevisionException;
import com.rbkmoney.cm.meta.UserIdentityEmailExtensionKit; import com.rbkmoney.cm.meta.UserIdentityEmailExtensionKit;
import com.rbkmoney.cm.meta.UserIdentityIdExtensionKit; import com.rbkmoney.cm.meta.UserIdentityIdExtensionKit;
import com.rbkmoney.cm.meta.UserIdentityRealmExtensionKit; import com.rbkmoney.cm.meta.UserIdentityRealmExtensionKit;
@ -15,7 +16,6 @@ import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.core.convert.ConversionService;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.scheduling.annotation.AsyncResult;
@ -38,9 +38,6 @@ public class ClaimCommitterServiceTest extends AbstractWithCommittersIntegration
@Autowired @Autowired
private ConversionWrapperService conversionWrapperService; private ConversionWrapperService conversionWrapperService;
@Autowired
private ConversionService conversionService;
@Autowired @Autowired
private ClaimManagementService claimManagementService; private ClaimManagementService claimManagementService;
@ -83,8 +80,12 @@ public class ClaimCommitterServiceTest extends AbstractWithCommittersIntegration
startSimpleCommitter(); startSimpleCommitter();
ClaimModel claimModel = createClaimWithPendingAcceptance("party_id"); ClaimModel claimModel = createClaimWithPendingAcceptance("party_id");
try {
claimCommitterService.doCommitClaim(claimModel.getPartyId(), claimModel.getId(), claimModel.getRevision() + 1); claimCommitterService.doCommitClaim(claimModel.getPartyId(), claimModel.getId(), claimModel.getRevision() + 1);
fail();
} catch (InvalidRevisionException ex) {
//do nothing
}
ClaimModel newClaimModel = claimManagementService.getClaim(claimModel.getPartyId(), claimModel.getId()); ClaimModel newClaimModel = claimManagementService.getClaim(claimModel.getPartyId(), claimModel.getId());
assertEquals(claimModel.getClaimStatus(), newClaimModel.getClaimStatus()); assertEquals(claimModel.getClaimStatus(), newClaimModel.getClaimStatus());
assertEquals(claimModel.getRevision(), newClaimModel.getRevision()); assertEquals(claimModel.getRevision(), newClaimModel.getRevision());