-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRMT-4112 Addressing SonarCloud code smells
- Loading branch information
1 parent
2994f42
commit dd1c916
Showing
14 changed files
with
56 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 19 additions & 31 deletions
50
src/test/java/uk/nhs/prm/repo/ehrtransferservice/models/ack/AcknowledgementTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,33 @@ | ||
package uk.nhs.prm.repo.ehrtransferservice.models.ack; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import uk.nhs.prm.repo.ehrtransferservice.gp2gp_message_models.AcknowledgementMessageWrapper; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class AcknowledgementTest { | ||
private AcknowledgementMessageWrapper acknowledgementMessageWrapper; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
acknowledgementMessageWrapper = new AcknowledgementMessageWrapper(); | ||
@ParameterizedTest | ||
@MethodSource("provideArgumentsForAcknowledgementType") | ||
void acknowledgementTypeCodeShouldBeNegativeAcknowledgement(String typeCode, boolean expected) { | ||
// given | ||
AcknowledgementMessageWrapper acknowledgementMessageWrapper = new AcknowledgementMessageWrapper(); | ||
acknowledgementMessageWrapper.acknowledgement = new AcknowledgementMessageWrapper.Acknowledgement(); | ||
} | ||
|
||
@Test | ||
public void shouldBeAPositiveAcknowledgementIfTypeIsAA() { | ||
acknowledgementMessageWrapper.acknowledgement.typeCode = "AA"; | ||
var ack = new Acknowledgement(null, acknowledgementMessageWrapper, "bob"); | ||
assertThat(ack.isNegativeAcknowledgement()).isFalse(); | ||
} | ||
|
||
@Test | ||
public void shouldBeANegativeAcknowledgementIfTypeIsAE() { | ||
acknowledgementMessageWrapper.acknowledgement.typeCode = "AE"; | ||
acknowledgementMessageWrapper.acknowledgement.typeCode = typeCode; | ||
var ack = new Acknowledgement(null, acknowledgementMessageWrapper, "bob"); | ||
assertThat(ack.isNegativeAcknowledgement()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void shouldBeANegativeAcknowledgementIfTypeIsAR() { | ||
acknowledgementMessageWrapper.acknowledgement.typeCode = "AR"; | ||
var ack = new Acknowledgement(null, acknowledgementMessageWrapper, "bob"); | ||
assertThat(ack.isNegativeAcknowledgement()).isTrue(); | ||
// then | ||
assertThat(ack.isNegativeAcknowledgement()).isEqualTo(expected); | ||
} | ||
|
||
@Test | ||
public void shouldBeANegativeAcknowledgementIfTypeIsUnknown() { | ||
acknowledgementMessageWrapper.acknowledgement.typeCode = "something that should never be set"; | ||
var ack = new Acknowledgement(null, acknowledgementMessageWrapper, "bob"); | ||
assertThat(ack.isNegativeAcknowledgement()).isTrue(); | ||
private static Stream<Arguments> provideArgumentsForAcknowledgementType() { | ||
return Stream.of( | ||
Arguments.of("AA", false), | ||
Arguments.of("AE", true), | ||
Arguments.of("AR", true), | ||
Arguments.of("something that should never be set", true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 16 additions & 22 deletions
38
...est/java/uk/nhs/prm/repo/ehrtransferservice/services/ehr_repo/StoreMessageResultTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
package uk.nhs.prm.repo.ehrtransferservice.services.ehr_repo; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import uk.nhs.prm.repo.ehrtransferservice.models.confirmmessagestored.StoreMessageResponseBody; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class StoreMessageResultTest { | ||
|
||
@Test | ||
public void ehrIsCompleteIfHealthRecordStatusIsComplete() { | ||
var result = new StoreMessageResult(new StoreMessageResponseBody("complete")); | ||
assertThat(result.isEhrComplete()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void ehrIsNotCompleteIfHealthRecordStatusIsAnythingOtherThanComplete() { | ||
var result = new StoreMessageResult(new StoreMessageResponseBody("not complete")); | ||
assertThat(result.isEhrComplete()).isFalse(); | ||
} | ||
|
||
@Test | ||
public void ehrIsNotCompleteIfHealthRecordStatusIsMissing() { | ||
var result = new StoreMessageResult(new StoreMessageResponseBody(null)); | ||
assertThat(result.isEhrComplete()).isFalse(); | ||
@ParameterizedTest | ||
@MethodSource("provideArgumentsForHealthRecordStatus") | ||
void ehrIsCompleteIfHealthRecordStatusIsComplete(String healthRecordStatus, boolean expected) { | ||
var result = new StoreMessageResult(new StoreMessageResponseBody(healthRecordStatus)); | ||
assertThat(result.isEhrComplete()).isEqualTo(expected); | ||
} | ||
|
||
@Test | ||
public void ehrIsNotCompleteIfHealthRecordStatusIsEmpty() { | ||
var result = new StoreMessageResult(new StoreMessageResponseBody("")); | ||
assertThat(result.isEhrComplete()).isFalse(); | ||
private static Stream<Arguments> provideArgumentsForHealthRecordStatus() { | ||
return Stream.of( | ||
Arguments.of("complete", true), | ||
Arguments.of("not complete", false), | ||
Arguments.of("", false), | ||
Arguments.of(null, false)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters