Skip to content

Commit

Permalink
Clean tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoet-jh committed Sep 25, 2023
1 parent beec66d commit d11aead
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected PassClient getNewClient() {

@Test
public void testUpdateSubmission_OptimisticLocking() throws IOException {
// GIVEN
Submission submission = new Submission();
submission.setAggregatedDepositStatus(AggregatedDepositStatus.NOT_STARTED);
submission.setSubmissionStatus(SubmissionStatus.DRAFT);
Expand All @@ -56,6 +57,7 @@ public void testUpdateSubmission_OptimisticLocking() throws IOException {
updateSub1.setSubmissionStatus(SubmissionStatus.SUBMITTED);
client.updateObject(updateSub1);

// WHEN/THEN
TransactionException transactionException = assertThrows(TransactionException.class, () -> {
updateSub2.setSource(null);
updateSub2.setSubmissionStatus(SubmissionStatus.CHANGES_REQUESTED);
Expand All @@ -70,6 +72,7 @@ public void testUpdateSubmission_OptimisticLocking() throws IOException {

@Test
public void testUpdateDeposit_OptimisticLocking() throws IOException {
// GIVEN
Deposit deposit = new Deposit();
deposit.setDepositStatus(DepositStatus.SUBMITTED);
client.createObject(deposit);
Expand All @@ -80,6 +83,7 @@ public void testUpdateDeposit_OptimisticLocking() throws IOException {
updateDep1.setDepositStatus(DepositStatus.FAILED);
client.updateObject(updateDep1);

// WHEN/THEN
TransactionException transactionException = assertThrows(TransactionException.class, () -> {
updateDep2.setDepositStatus(DepositStatus.ACCEPTED);
client.updateObject(updateDep2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,24 @@ protected PassClient getNewClient() {

@Test
public void testUpdateObject_CheckVersionUpdate() throws IOException {
// GIVEN
Submission submission = new Submission();

submission.setAggregatedDepositStatus(AggregatedDepositStatus.NOT_STARTED);
submission.setSubmissionStatus(SubmissionStatus.DRAFT);
submission.setSubmitterName("Bessie");

// WHEN
client.createObject(submission);

// THEN
assertEquals(0, submission.getVersion());

// WHEN
submission.setSource(Source.OTHER);
submission.setSubmissionStatus(SubmissionStatus.SUBMITTED);

client.updateObject(submission);

// THEN
assertEquals(1, submission.getVersion());

Submission test = client.getObject(submission.getClass(), submission.getId());
Expand All @@ -74,6 +79,7 @@ public void testUpdateObject_CheckVersionUpdate() throws IOException {

@Test
public void testUpdateSubmission_OptimisticLocking() throws IOException {
// GIVEN
Submission submission = new Submission();
submission.setAggregatedDepositStatus(AggregatedDepositStatus.NOT_STARTED);
submission.setSubmissionStatus(SubmissionStatus.DRAFT);
Expand All @@ -89,6 +95,7 @@ public void testUpdateSubmission_OptimisticLocking() throws IOException {
updateSub1.setSubmissionStatus(SubmissionStatus.SUBMITTED);
client.updateObject(updateSub1);

// WHEN/THEN
IOException ioException = assertThrows(IOException.class, () -> {
updateSub2.setSource(null);
updateSub2.setSubmissionStatus(SubmissionStatus.CHANGES_REQUESTED);
Expand All @@ -102,6 +109,7 @@ public void testUpdateSubmission_OptimisticLocking() throws IOException {

@Test
public void testUpdateSubmission_OptimisticLocking_NullVersion() throws IOException {
// GIVEN
Submission submission = new Submission();
submission.setAggregatedDepositStatus(AggregatedDepositStatus.NOT_STARTED);
submission.setSubmissionStatus(SubmissionStatus.DRAFT);
Expand All @@ -116,6 +124,7 @@ public void testUpdateSubmission_OptimisticLocking_NullVersion() throws IOExcept

client.updateObject(updateSub1);

// WHEN/THEN
IOException ioException = assertThrows(IOException.class, () -> {
updateSub2.setSource(null);
updateSub2.setSubmissionStatus(SubmissionStatus.CHANGES_REQUESTED);
Expand All @@ -130,6 +139,7 @@ public void testUpdateSubmission_OptimisticLocking_NullVersion() throws IOExcept

@Test
public void testUpdateDeposit_OptimisticLocking() throws IOException {
// GIVEN
Deposit deposit = new Deposit();
deposit.setDepositStatus(DepositStatus.SUBMITTED);
client.createObject(deposit);
Expand All @@ -142,6 +152,7 @@ public void testUpdateDeposit_OptimisticLocking() throws IOException {
updateDep1.setDepositStatus(DepositStatus.FAILED);
client.updateObject(updateDep1);

// WHEN/THEN
IOException ioException = assertThrows(IOException.class, () -> {
updateDep2.setDepositStatus(DepositStatus.ACCEPTED);
client.updateObject(updateDep2);
Expand All @@ -154,6 +165,7 @@ public void testUpdateDeposit_OptimisticLocking() throws IOException {

@Test
public void testUpdateDeposit_OptimisticLocking_NullVersion() throws IOException {
// GIVEN
Deposit deposit = new Deposit();
deposit.setDepositStatus(DepositStatus.SUBMITTED);
client.createObject(deposit);
Expand All @@ -164,6 +176,7 @@ public void testUpdateDeposit_OptimisticLocking_NullVersion() throws IOException
updateDep1.setDepositStatus(DepositStatus.FAILED);
client.updateObject(updateDep1);

// WHEN/THEN
IOException ioException = assertThrows(IOException.class, () -> {
updateDep2.setDepositStatus(DepositStatus.ACCEPTED);
ReflectionTestUtils.setField(updateDep2, "version", null);
Expand Down

0 comments on commit d11aead

Please sign in to comment.