ConfigureDelegator extends BaseDelegator implements IConfigureDelegator { @Override public List<ServerConfigurationValue> showServerConfiguration(final String serverName, final String variableName) throws P4JavaException { String[] args = new String[]{SHOW_CMD}; if (isNotBlank(serverName)) { args = new String[]{SHOW_CMD, serverName}; } else if (isNotBlank(variableName)) { args = new String[]{SHOW_CMD, variableName}; } List<Map<String, Object>> resultMaps = execMapCmdList(CONFIGURE, args, null); return ResultListBuilder.buildNonNullObjectListFromCommandResultMaps(resultMaps, new Function<Map<String, Object>, ServerConfigurationValue>() { @Override public ServerConfigurationValue apply(Map<String, Object> map) { return new ServerConfigurationValue(map); } }); } ConfigureDelegator(final IOptionsServer server); @Override String setOrUnsetServerConfigurationValue(@Nonnull final String name,
                                                     @Nullable final String value); @Override List<ServerConfigurationValue> showServerConfiguration(final String serverName,
                                                                  final String variableName);  }
@Test public void testShowServerConfigurationForName() throws P4JavaException { when(server.execMapCmdList(eq(CmdSpec.CONFIGURE.toString()), argThat(SERVER_NAME_MATCHER), eq(null))).thenReturn(buildShowList(SERVER_NAME)); List<ServerConfigurationValue> values = configureDelegator .showServerConfiguration(SERVER_NAME, null); verify(server).execMapCmdList(eq(CmdSpec.CONFIGURE.toString()), argThat(SERVER_NAME_MATCHER), eq(null)); assertValues(values, SERVER_NAME); }
@Test public void testShowServerConfigurationForValue() throws P4JavaException { when(server.execMapCmdList(eq(CmdSpec.CONFIGURE.toString()), argThat(SHOW_ANY_MATCHER), eq(null))).thenReturn(buildShowList(null)); List<ServerConfigurationValue> values = configureDelegator.showServerConfiguration(null, ANY); verify(server).execMapCmdList(eq(CmdSpec.CONFIGURE.toString()), argThat(SHOW_ANY_MATCHER), eq(null)); assertValues(values, null); assertFound(values, new ServerConfigurationValue(ANY, ConfigType.OPTION, ANY, ANY_VALUE)); }
@Test public void testShowServerConfiguration() throws P4JavaException { when(server.execMapCmdList(eq(CmdSpec.CONFIGURE.toString()), argThat(SHOW_MATCHER), eq(null))).thenReturn(buildShowList(null)); List<ServerConfigurationValue> values = configureDelegator.showServerConfiguration(null, null); verify(server).execMapCmdList(eq(CmdSpec.CONFIGURE.toString()), argThat(SHOW_MATCHER), eq(null)); assertValues(values, null); }