-
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.
- Loading branch information
Showing
7 changed files
with
85 additions
and
60 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
18 changes: 0 additions & 18 deletions
18
.../nhs/prm/repo/ehrtransferservice/models/sendEhrRequest/RegistrationRequestAttributes.java
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
...ava/uk/nhs/prm/repo/ehrtransferservice/models/sendEhrRequest/RegistrationRequestBody.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
...ava/uk/nhs/prm/repo/ehrtransferservice/models/sendEhrRequest/RegistrationRequestData.java
This file was deleted.
Oops, something went wrong.
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
58 changes: 58 additions & 0 deletions
58
src/test/java/uk/nhs/prm/repo/ehrtransferservice/parsers/LargeSqsMessageParserTest.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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package uk.nhs.prm.repo.ehrtransferservice.parsers; | ||
|
||
import com.fasterxml.jackson.core.JsonParseException; | ||
import com.google.common.base.Charsets; | ||
import com.google.common.io.ByteSource; | ||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import uk.nhs.prm.repo.ehrtransferservice.models.LargeSqsMessage; | ||
import uk.nhs.prm.repo.ehrtransferservice.utils.TestDataLoader; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class LargeSqsMessageParserTest { | ||
|
||
private final LargeSqsMessageParser parser = new LargeSqsMessageParser(); | ||
private final TestDataLoader loader = new TestDataLoader(); | ||
|
||
@SuppressFBWarnings | ||
private InputStream readResourceFile(String resourceFileName) throws FileNotFoundException { | ||
return new FileInputStream("src/test/resources/data/" + resourceFileName); | ||
} | ||
|
||
@Test | ||
void shouldParseLargeSQSMessage() throws IOException { | ||
String messageAsString = loader.getDataAsString("RCMR_IN030000UK06"); | ||
|
||
var result = parser.parse(messageAsString); | ||
|
||
assertEquals(result.getClass(), LargeSqsMessage.class); | ||
} | ||
|
||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
"simpleTextMessage.txt", | ||
"RCMR_IN030000UK06WithoutInteractionId", | ||
"RCMR_IN030000UK06WithoutMessageHeader", | ||
"RCMR_IN030000UK06WithoutSoapHeader", | ||
"RCMR_IN030000UK06WithIncorrectInteractionId" | ||
}) | ||
void shouldThrowJsonParseExceptionWhenCannotParseMessage(String fileName) throws IOException { | ||
String messageAsString = loader.getDataAsString(fileName); | ||
|
||
Exception expected = assertThrows(JsonParseException.class, () -> | ||
parser.parse(messageAsString) | ||
); | ||
assertThat(expected, notNullValue()); | ||
} | ||
} |