Skip to content

Commit 1547912

Browse files
committed
Refactoring
1 parent 029c4ec commit 1547912

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

omod/src/main/java/org/openmrs/module/smartonfhir/web/servlet/SmartLaunchOptionSelected.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOExce
4444
String visitId = getParameter(req, "visitId");
4545

4646
if (token == null) {
47-
res.sendError(HttpServletResponse.SC_BAD_REQUEST, "Couldn't found token in url");
47+
res.sendError(HttpServletResponse.SC_BAD_REQUEST, "Couldn't find token in url");
4848
return;
4949
}
5050

omod/src/test/java/org.openmrs.module.smartonfhir/web/servlet/SmartAccessConfirmationTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
package org.openmrs.module.smartonfhir.web.servlet;
1111

1212
import static org.hamcrest.MatcherAssert.assertThat;
13+
import static org.hamcrest.Matchers.containsString;
1314
import static org.hamcrest.Matchers.equalTo;
1415
import static org.hamcrest.Matchers.notNullValue;
16+
import static org.mockito.Mockito.when;
1517
import static org.powermock.api.mockito.PowerMockito.doReturn;
1618
import static org.powermock.api.mockito.PowerMockito.mockStatic;
17-
import static org.powermock.api.mockito.PowerMockito.when;
1819
import static org.powermock.api.mockito.PowerMockito.whenNew;
1920

2021
import javax.crypto.spec.SecretKeySpec;
@@ -104,7 +105,7 @@ public void shouldReturnCorrectBaseURL() throws IOException {
104105

105106
assertThat(response, notNullValue());
106107
assertThat(response.getRedirectedUrl(), notNullValue());
107-
assertThat(response.getRedirectedUrl().contains(BASE_URL), equalTo(true));
108+
assertThat(response.getRedirectedUrl(), containsString(BASE_URL));
108109
}
109110

110111
@Test
@@ -113,8 +114,8 @@ public void shouldContainsEveryQuery() throws IOException {
113114

114115
assertThat(response, notNullValue());
115116
assertThat(response.getRedirectedUrl(), notNullValue());
116-
assertThat(response.getRedirectedUrl().contains("key="), equalTo(true));
117-
assertThat(response.getRedirectedUrl().contains("app-token="), equalTo(true));
117+
assertThat(response.getRedirectedUrl(), containsString("key="));
118+
assertThat(response.getRedirectedUrl(), containsString("app-token="));
118119
}
119120

120121
@Test

omod/src/test/java/org.openmrs.module.smartonfhir/web/servlet/SmartAppSelectorServletTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
package org.openmrs.module.smartonfhir.web.servlet;
1111

1212
import static org.hamcrest.MatcherAssert.assertThat;
13+
import static org.hamcrest.Matchers.containsString;
1314
import static org.hamcrest.Matchers.equalTo;
1415
import static org.hamcrest.Matchers.notNullValue;
15-
import static org.powermock.api.mockito.PowerMockito.when;
16+
import static org.mockito.Mockito.when;
1617
import static org.powermock.api.mockito.PowerMockito.whenNew;
1718

1819
import java.io.IOException;
@@ -63,7 +64,7 @@ public void shouldReturnCorrectSMARTAppBaseURLForR4() throws IOException {
6364

6465
assertThat(response, notNullValue());
6566
assertThat(response.getRedirectedUrl(), notNullValue());
66-
assertThat(response.getRedirectedUrl().contains(SMART_APP_BASE_URL), equalTo(true));
67+
assertThat(response.getRedirectedUrl(), containsString(SMART_APP_BASE_URL));
6768
assertThat(response.getRedirectedUrl(), equalTo(BASE_LAUNCH_ADDRESS_R4));
6869
}
6970

@@ -75,7 +76,7 @@ public void shouldReturnCorrectSMARTAppBaseURLForR3() throws IOException {
7576

7677
assertThat(response, notNullValue());
7778
assertThat(response.getRedirectedUrl(), notNullValue());
78-
assertThat(response.getRedirectedUrl().contains(SMART_APP_BASE_URL), equalTo(true));
79+
assertThat(response.getRedirectedUrl(), containsString(SMART_APP_BASE_URL));
7980
assertThat(response.getRedirectedUrl(), equalTo(BASE_LAUNCH_ADDRESS_R3));
8081
}
8182

@@ -87,6 +88,6 @@ public void shouldContainsEveryQuery() throws IOException {
8788

8889
assertThat(response, notNullValue());
8990
assertThat(response.getRedirectedUrl(), notNullValue());
90-
assertThat(response.getRedirectedUrl().contains("iss="), equalTo(true));
91+
assertThat(response.getRedirectedUrl(), containsString("iss="));
9192
}
9293
}

omod/src/test/java/org.openmrs.module.smartonfhir/web/servlet/SmartEhrLaunchServletTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import static org.hamcrest.MatcherAssert.assertThat;
1313
import static org.hamcrest.Matchers.equalTo;
1414
import static org.hamcrest.Matchers.notNullValue;
15-
import static org.powermock.api.mockito.PowerMockito.when;
15+
import static org.mockito.Mockito.when;
1616
import static org.powermock.api.mockito.PowerMockito.whenNew;
1717

1818
import java.io.IOException;

omod/src/test/java/org.openmrs.module.smartonfhir/web/servlet/SmartLaunchOptionSelectedTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.openmrs.module.smartonfhir.web.servlet;
1111

1212
import static org.hamcrest.MatcherAssert.assertThat;
13+
import static org.hamcrest.Matchers.containsString;
1314
import static org.hamcrest.Matchers.equalTo;
1415
import static org.hamcrest.Matchers.notNullValue;
1516
import static org.powermock.api.mockito.PowerMockito.doReturn;
@@ -69,8 +70,8 @@ public void shouldReturnCorrectURLWhenLaunchTypeIsEncounter() throws IOException
6970

7071
assertThat(response, notNullValue());
7172
assertThat(response.getRedirectedUrl(), notNullValue());
72-
assertThat(response.getRedirectedUrl().contains("app=smartonfhir.search.visit"), equalTo(true));
73-
assertThat(response.getRedirectedUrl().contains("patientId=12345"), equalTo(true));
73+
assertThat(response.getRedirectedUrl(), containsString("app=smartonfhir.search.visit"));
74+
assertThat(response.getRedirectedUrl(), containsString("patientId=12345"));
7475
}
7576

7677
@Test
@@ -82,8 +83,8 @@ public void shouldReturnCorrectURLWhenLaunchTypeIsPatient() throws IOException {
8283

8384
assertThat(response, notNullValue());
8485
assertThat(response.getRedirectedUrl(), notNullValue());
85-
assertThat(response.getRedirectedUrl().contains("key="), equalTo(true));
86-
assertThat(response.getRedirectedUrl().contains("app-token="), equalTo(true));
86+
assertThat(response.getRedirectedUrl(), containsString("key="));
87+
assertThat(response.getRedirectedUrl(), containsString("app-token="));
8788
}
8889

8990
@Test
@@ -96,8 +97,8 @@ public void shouldReturnCorrectRedirectURlWhenLaunchTypeIsEncounter() throws IOE
9697

9798
assertThat(response, notNullValue());
9899
assertThat(response.getRedirectedUrl(), notNullValue());
99-
assertThat(response.getRedirectedUrl().contains("key="), equalTo(true));
100-
assertThat(response.getRedirectedUrl().contains("app-token="), equalTo(true));
100+
assertThat(response.getRedirectedUrl(), containsString("key="));
101+
assertThat(response.getRedirectedUrl(), containsString("app-token="));
101102
}
102103

103104
@Test
@@ -116,6 +117,6 @@ public void shouldThrowErrorWhenTokenIsNull() throws IOException {
116117

117118
assertThat(response, notNullValue());
118119
assertThat(response.getErrorMessage(), notNullValue());
119-
assertThat(response.getErrorMessage(), equalTo("Couldn't found token in url"));
120+
assertThat(response.getErrorMessage(), equalTo("Couldn't find token in url"));
120121
}
121122
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@
328328
<groupId>com.fasterxml.jackson.core</groupId>
329329
<artifactId>jackson-databind</artifactId>
330330
<version>2.7.3</version>
331+
<scope>provided</scope>
331332
</dependency>
332333

333334
</dependencies>

0 commit comments

Comments
 (0)