Skip to content

Commit

Permalink
Add more unit tests for Optional support
Browse files Browse the repository at this point in the history
  • Loading branch information
ralscha committed Oct 10, 2014
1 parent c48dc81 commit 77b21e0
Show file tree
Hide file tree
Showing 4 changed files with 540 additions and 903 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ private MvcResult doTest(String url, ApiRequestParams params, RemotingApi expect
return doTest(mockMvc, url, params, expectedApi);
}

private static MvcResult doTest(MockMvc mockMvc, String url, ApiRequestParams params,
public static MvcResult doTest(MockMvc mockMvc, String url, ApiRequestParams params,
RemotingApi expectedApi) throws Exception {
MockHttpServletRequestBuilder request = get(url).accept(MediaType.ALL)
.characterEncoding("UTF-8");
Expand Down Expand Up @@ -455,7 +455,7 @@ else if (params.getConfiguration() != null) {
return result;
}

private static RemotingApi noApis(String namespace) {
public static RemotingApi noApis(String namespace) {
return new RemotingApi("remoting", "/router", namespace);
}

Expand Down Expand Up @@ -497,7 +497,7 @@ static RemotingApi groupApisWithDoc(String namespace) {
return remotingApi;
}

private static RemotingApi group2Apis(String namespace, String url) {
public static RemotingApi group2Apis(String namespace, String url) {
RemotingApi remotingApi = new RemotingApi("remoting", url, namespace);
remotingApi.addAction("remoteProviderSimple", new Action("method3", 3,
Boolean.FALSE));
Expand Down Expand Up @@ -530,7 +530,7 @@ private static RemotingApi group2Apis(String namespace, String url) {
return remotingApi;
}

private static RemotingApi group1and2Apis(String namespace) {
public static RemotingApi group1and2Apis(String namespace) {
RemotingApi remotingApi = new RemotingApi("remoting", "/router", namespace);
remotingApi.addAction("remoteProviderSimple", new Action("method1", 0,
Boolean.FALSE));
Expand Down Expand Up @@ -572,7 +572,7 @@ static RemotingApi group2Apis(String namespace) {
return group2Apis(namespace, "/router");
}

private static RemotingApi group3Apis(String namespace) {
public static RemotingApi group3Apis(String namespace) {
RemotingApi remotingApi = new RemotingApi("remoting", "/router", namespace);
remotingApi.addAction("remoteProviderSimple", new Action("method5", 1,
Boolean.FALSE));
Expand Down Expand Up @@ -606,15 +606,15 @@ private static RemotingApi group3Apis(String namespace) {
return remotingApi;
}

private static RemotingApi group4Apis(String namespace) {
public static RemotingApi group4Apis(String namespace) {
RemotingApi remotingApi = new RemotingApi("remoting", "/router", namespace);
remotingApi.addPollingProvider(new PollingProvider("pollProvider",
"handleMessage3", "message3"));
remotingApi.addSseProvider("sseProvider", "message3");
return remotingApi;
}

private static RemotingApi interfaceApis(String namespace) {
public static RemotingApi interfaceApis(String namespace) {
RemotingApi remotingApi = new RemotingApi("remoting", "/router", namespace);
remotingApi.addAction("remoteProviderImplementation", new Action("storeRead", 1,
Boolean.FALSE));
Expand All @@ -625,7 +625,7 @@ private static RemotingApi interfaceApis(String namespace) {
return remotingApi;
}

private static RemotingApi allApis(String namespace) {
public static RemotingApi allApis(String namespace) {
RemotingApi remotingApi = new RemotingApi("remoting", "/router", namespace);
remotingApi.addAction("remoteProviderSimple", new Action("method1", 0,
Boolean.FALSE));
Expand Down Expand Up @@ -997,10 +997,43 @@ private static RemotingApi allApis(String namespace) {
remotingApi.addSseProvider("sseProvider", "message13");
remotingApi.addSseProvider("sseProvider", "message14");
remotingApi.addSseProvider("sseProvider", "message15");

remotingApi.addAction("remoteProviderOptional", new Action("method1", 3,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method2", 1,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method4", 2,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method5", 1,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method6", 0,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method7", 0,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method8", 1,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method9", 0,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method10", 3,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method11", 3,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method12", 3,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method13", 3,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method16", 0,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method17", 0,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method18", 0,
Boolean.FALSE));
remotingApi.addAction("remoteProviderOptional", new Action("method19", 0,
Boolean.FALSE));
return remotingApi;
}

private static RemotingApi emptyGroupApis(String namespace) {
public static RemotingApi emptyGroupApis(String namespace) {
RemotingApi remotingApi = new RemotingApi("remoting", "/router", namespace);
remotingApi.addAction("remoteProviderSimple", new Action("method2", 0,
Boolean.FALSE));
Expand Down Expand Up @@ -1156,7 +1189,7 @@ private static RemotingApi emptyGroupApis(String namespace) {
}

@SuppressWarnings("unchecked")
private static void compareJson(MvcResult result, RemotingApi remotingApi,
public static void compareJson(MvcResult result, RemotingApi remotingApi,
ApiRequestParams params) throws IOException {
String content = result.getResponse().getContentAsString();
assertThat(result.getResponse().getContentType()).isEqualTo(
Expand Down Expand Up @@ -1431,7 +1464,7 @@ public static void compare(String contentString, String contentTypeString,
}
}

private static void compareSse(List<String> expectedActions,
public static void compareSse(List<String> expectedActions,
Map<String, String> actions, String beanName, String url) {
assertThat(actions).isNotEmpty();
assertThat(actions).hasSize(expectedActions.size());
Expand All @@ -1443,7 +1476,7 @@ private static void compareSse(List<String> expectedActions,
}

@SuppressWarnings({ "null", "unchecked" })
private static void compare(List<Action> expectedActions,
public static void compare(List<Action> expectedActions,
List<Map<String, Object>> actions) {
assertThat(actions).hasSize(expectedActions.size());
for (Action expectedAction : expectedActions) {
Expand Down Expand Up @@ -1479,7 +1512,7 @@ private static void compare(List<Action> expectedActions,
}

@SuppressWarnings("null")
private static int assertContains(String extNsLine, String[] lines) {
public static int assertContains(String extNsLine, String[] lines) {
if (lines == null) {
fail("no lines");
}
Expand All @@ -1496,7 +1529,7 @@ private static int assertContains(String extNsLine, String[] lines) {
}

@SuppressWarnings("null")
private static void assertDoesNotContains(String extNsLine, String[] lines) {
public static void assertDoesNotContains(String extNsLine, String[] lines) {
if (lines == null) {
fail("no lines");
}
Expand Down
Loading

0 comments on commit 77b21e0

Please sign in to comment.