Skip to content

Commit

Permalink
Merge pull request #91 from simonweiser/master
Browse files Browse the repository at this point in the history
Add transactionId to validation method of StartTransactionConfirmation
  • Loading branch information
TVolden authored Feb 13, 2019
2 parents 0f3e760 + 588d6aa commit 2ee40bc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public StartTransactionConfirmation handleStartTransactionRequest(UUID sessionIn

StartTransactionConfirmation confirmation = new StartTransactionConfirmation();
confirmation.setIdTagInfo(tagInfo);
confirmation.setTransactionId(42);
return failurePoint(confirmation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public boolean validate() {
boolean valid = true;
if (valid &= idTagInfo != null)
valid &= idTagInfo.validate();
valid &= transactionId != null;
return valid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,33 @@ public void validate_returnFalse() {
}

@Test
public void validate_idTagInfoAndTransactionIdIsSet_idTagInfoIsValidated() throws Exception {
public void validate_idTagInfoIsNotSetAndTransactionIdIsSet_returnFalse() {
// Given
confirmation.setTransactionId(42);

// When
boolean isValid = confirmation.validate();

// Then
assertThat(isValid, is(false));
}

@Test
public void validate_idTagInfoIsSetAndTransactionIdIsNotSet_returnFalse() {
// Given
IdTagInfo idTagInfo = mock(IdTagInfo.class);
when(idTagInfo.validate()).thenReturn(true);
confirmation.setIdTagInfo(idTagInfo);

// When
boolean isValid = confirmation.validate();

// Then
assertThat(isValid, is(false));
}

@Test
public void validate_idTagInfoAndTransactionIdIsSet_idTagInfoIsValidated() {
// Given
confirmation.setTransactionId(42);
IdTagInfo idTagInfo = mock(IdTagInfo.class);
Expand All @@ -91,7 +117,7 @@ public void validate_idTagInfoAndTransactionIdIsSet_idTagInfoIsValidated() throw
}

@Test
public void validate_idTagInfoAndTransactionIdIsSet_returnTrue() throws Exception {
public void validate_idTagInfoAndTransactionIdIsSet_returnTrue() {
// Given
confirmation.setTransactionId(42);
IdTagInfo idTagInfo = mock(IdTagInfo.class);
Expand Down

0 comments on commit 2ee40bc

Please sign in to comment.