Add tests for link builder

This commit is contained in:
Tadgh 2021-07-01 09:43:53 -04:00
parent b963520c98
commit 86519a892a
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
package ca.uhn.fhir.mdm.api.paging;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.*;
class MdmPageLinkBuilderTest {
@Test
void buildLinkWithExistingParameters() {
//Given
String expected = "http://localhost:8000/$mdm-query-links?sourceResourceId=Patient/123&_offset=1&_count=1";
String baseUrl = "http://localhost:8000/$mdm-query-links?sourceResourceId=Patient/123";
//When
String builtUrl = MdmPageLinkBuilder.buildLinkWithOffsetAndCount(baseUrl, 1, 1);
//Then
assertThat(builtUrl, is(equalTo(expected)));
}
@Test
void buildLinkWithoutExistingParameters() {
//Given
String expected = "http://localhost:8000/$mdm-query-links?_offset=1&_count=1";
String baseUrl = "http://localhost:8000/$mdm-query-links";
//When
String builtUrl = MdmPageLinkBuilder.buildLinkWithOffsetAndCount(baseUrl, 1, 1);
//Then
assertThat(builtUrl, is(equalTo(expected)));
}
}