InfoDelegator extends BaseDelegator implements IInfoDelegator { @Override public IServerInfo getServerInfo() throws ConnectionException, RequestException, AccessException { ServerInfo serverInfo = new ServerInfo(); List<Map<String, Object>> resultMaps = execMapCmdList(INFO, new String[0], null); if (nonNull(resultMaps)) { List<Map<String, Object>> validMaps = new ArrayList<>(); for (int i = 0; i < resultMaps.size(); i++) { Map<String, Object> map = resultMaps.get(i); String errStr = ResultMapParser.getErrorStr(map); throwRequestExceptionIfConditionFails(isBlank(errStr), parseCode0ErrorString(map), errStr); validMaps.add(map); } serverInfo = new ServerInfo(validMaps); } return serverInfo; } InfoDelegator(final IOptionsServer server); @Override IServerInfo getServerInfo();  }
@Test(expected = ConnectionException.class) public void testInfoConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq((Map<String, Object>)null))) .thenThrow(ConnectionException.class); infoDelegator.getServerInfo(); }
@Test(expected = AccessException.class) public void testInfoAccessException() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq((Map<String, Object>)null))) .thenThrow(AccessException.class); infoDelegator.getServerInfo(); }
@Test(expected = RequestException.class) public void testInfoRequestException() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq((Map<String, Object>)null))) .thenThrow(RequestException.class); infoDelegator.getServerInfo(); }
@Test(expected = P4JavaException.class) public void testInfoP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq((Map<String, Object>)null))) .thenThrow(P4JavaException.class); infoDelegator.getServerInfo(); }
@Test public void testInfo() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildValidResultMap()); assertInfo(infoDelegator.getServerInfo()); }
@Test(expected = ConnectionException.class) public void testInfoConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq(null))) .thenThrow(ConnectionException.class); infoDelegator.getServerInfo(); }
@Test(expected = AccessException.class) public void testInfoAccessException() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq(null))) .thenThrow(AccessException.class); infoDelegator.getServerInfo(); }
@Test(expected = RequestException.class) public void testInfoRequestException() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq(null))) .thenThrow(RequestException.class); infoDelegator.getServerInfo(); }
@Test(expected = P4JavaException.class) public void testInfoP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq(null))) .thenThrow(P4JavaException.class); infoDelegator.getServerInfo(); }
@Test public void testInfo() throws P4JavaException { when(server.execMapCmdList(eq(INFO.toString()), argThat(INFO_MATCHER), eq(null))) .thenReturn(buildValidResultMap()); assertInfo(infoDelegator.getServerInfo()); }