Skip to content

Commit b4449d8

Browse files
committed
- code-linting: replaces multiple tests by paramaterized
1 parent a7d18c5 commit b4449d8

File tree

3 files changed

+13
-32
lines changed

3 files changed

+13
-32
lines changed

gradle/dependencies.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
dependencies {
22
// Use JUnit test framework
33
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
4+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.1'
45
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
56
testImplementation 'org.mockito:mockito-inline:4.0.0'
67

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
<version>5.8.1</version>
4444
<scope>test</scope>
4545
</dependency>
46+
<dependency>
47+
<groupId>org.junit.jupiter</groupId>
48+
<artifactId>junit-jupiter-params</artifactId>
49+
<version>5.8.1</version>
50+
<scope>test</scope>
51+
</dependency>
4652
<dependency>
4753
<groupId>org.mockito</groupId>
4854
<artifactId>mockito-inline</artifactId>

src/test/java/com/microsoft/graph/content/BatchRequestContentTest.java

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import com.microsoft.graph.serializer.ISerializer;
3131

3232
import org.junit.jupiter.api.Test;
33+
import org.junit.jupiter.params.ParameterizedTest;
34+
import org.junit.jupiter.params.provider.ValueSource;
3335

3436
import okhttp3.Call;
3537
import okhttp3.MediaType;
@@ -66,39 +68,11 @@ void testGetBatchRequestContent() throws MalformedURLException {
6668
assertEquals(expectedContent, content);
6769
}
6870

69-
@Test
70-
void testItReplacesChinaHost() throws MalformedURLException {
71-
IHttpRequest requestStep = mock(IHttpRequest.class);
72-
when(requestStep.getRequestUrl()).thenReturn(new URL("https://microsoftgraph.chinacloudapi.cn/v1.0/me"));
73-
BatchRequestContent requestContent = new BatchRequestContent();
74-
requestContent.addBatchRequestStep(requestStep);
75-
var step = requestContent.requests.get(0);
76-
assertEquals("/me", step.url);
77-
}
78-
79-
@Test
80-
void testItReplacesGCCHost() throws MalformedURLException {
81-
IHttpRequest requestStep = mock(IHttpRequest.class);
82-
when(requestStep.getRequestUrl()).thenReturn(new URL("https://graph.microsoft.us/v1.0/me"));
83-
BatchRequestContent requestContent = new BatchRequestContent();
84-
requestContent.addBatchRequestStep(requestStep);
85-
var step = requestContent.requests.get(0);
86-
assertEquals("/me", step.url);
87-
}
88-
89-
@Test
90-
void testItReplacesDODHost() throws MalformedURLException {
91-
IHttpRequest requestStep = mock(IHttpRequest.class);
92-
when(requestStep.getRequestUrl()).thenReturn(new URL("https://dod-graph.microsoft.us/v1.0/me"));
93-
BatchRequestContent requestContent = new BatchRequestContent();
94-
requestContent.addBatchRequestStep(requestStep);
95-
var step = requestContent.requests.get(0);
96-
assertEquals("/me", step.url);
97-
}
98-
@Test
99-
void testItReplacesGermanHost() throws MalformedURLException {
71+
@ParameterizedTest
72+
@ValueSource(strings = { "https://microsoftgraph.chinacloudapi.cn/v1.0/me", "https://graph.microsoft.com/v1.0/me", "https://graph.microsoft.us/v1.0/me", "https://dod-graph.microsoft.us/v1.0/me", "https://graph.microsoft.de/v1.0/me"})
73+
void testItReplacesNationalHost(final String url) throws MalformedURLException {
10074
IHttpRequest requestStep = mock(IHttpRequest.class);
101-
when(requestStep.getRequestUrl()).thenReturn(new URL("https://graph.microsoft.de/v1.0/me"));
75+
when(requestStep.getRequestUrl()).thenReturn(new URL(url));
10276
BatchRequestContent requestContent = new BatchRequestContent();
10377
requestContent.addBatchRequestStep(requestStep);
10478
var step = requestContent.requests.get(0);

0 commit comments

Comments
 (0)