ClientDelegator extends BaseDelegator implements IClientDelegator { @Override public String switchStreamView(final String streamPath, final String targetClientName, final SwitchClientViewOptions opts) throws P4JavaException { Validate.notBlank(streamPath, "Stream path shouldn't blank"); List<String> args = new ArrayList<>(Arrays.asList("-s", "-S", streamPath)); if (isNotBlank(targetClientName)) { args.add(targetClientName); } List<Map<String, Object>> resultMaps = execMapCmdList( CLIENT, processParameters( opts, null, args.toArray(new String[args.size()]), server), null); return parseCommandResultMapIfIsInfoMessageAsString(resultMaps); } ClientDelegator(IOptionsServer server); @Override IClient getClient(final String clientName); @Override IClient getClient(@Nonnull IClientSummary clientSummary); @Override IClient getClientTemplate(String clientName); @Override IClient getClientTemplate(final String clientName, final boolean allowExistent); @Override IClient getClientTemplate(
			@Nonnull String clientName,
			GetClientTemplateOptions getClientTemplateOptions); @Override String createClient(@Nonnull final IClient newClient); @Override void createTempClient(@Nonnull final IClient newClient); @Override String updateClient(@Nonnull final IClient client); @Override String updateClient(@Nonnull final IClient client, final boolean force); @Override String updateClient(@Nonnull final IClient client, final UpdateClientOptions opts); @Override String deleteClient(final String clientName, final boolean force); @Override String deleteClient(final String clientName, final DeleteClientOptions opts); String switchClientView(final String templateClientName,
								   final String targetClientName,
								   final SwitchClientViewOptions opts); @Override String switchStreamView(final String streamPath,
								   final String targetClientName,
								   final SwitchClientViewOptions opts);  }
@Test public void switchStreamView_byStreamPathTargetNameAndSwitchClientViewOptions_shouldThrownIllegalArgumentExceptionWhenStreamPathIsBlank() throws Exception { thrown.expect(IllegalArgumentException.class); clientDelegator.switchStreamView(EMPTY, "myTargetClient", mockSwitchClientViewOptions); }
@Test public void switchStreamView_byStreamPathTargetNameAndSwitchClientViewOptions_shouldReturnSwitchedStreamViewName() throws Exception { when(server.execMapCmdList(eq(CLIENT.toString()), any(String[].class), eq(null))).thenReturn(resultMaps); givenInfoMessageResultMap(); String switchStreamView = clientDelegator.switchStreamView( "streamPath", "myTargetClient", mockSwitchClientViewOptions); assertThat(switchStreamView, is(clientName)); }
@Test(expected = IllegalArgumentException.class) public void switchStreamView_byStreamPathTargetNameAndSwitchClientViewOptions_shouldThrownIllegalArgumentExceptionWhenStreamPathIsBlank() throws Exception { clientDelegator.switchStreamView(EMPTY, "myTargetClient", mockSwitchClientViewOptions); }
@Test public void switchStreamView_byStreamPathTargetNameAndSwitchClientViewOptions_shouldReturnSwitchedStreamViewName() throws Exception { when(server.execMapCmdList(eq(CLIENT.toString()), any(String[].class), eq((Map<String, Object>) null))).thenReturn(resultMaps); givenInfoMessageResultMap(); String switchStreamView = clientDelegator.switchStreamView("streamPath", "myTargetClient", mockSwitchClientViewOptions); assertThat(switchStreamView, is(clientName)); }