Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transactionId to validation method of StartTransactionConfirmation #91

Merged
merged 2 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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