LocalPeerCommands { protected RequestBuilder getChangeHostnameInEtcHostsCommand( String oldHostname, String newHostname ) { return new RequestBuilder( String.format( "sed -i 's/\\b%1$s\\b/%2$s/g' %4$s && sed -i 's/\\b%1$s.%3$s\\b/%2$s.%3$s/g' %4$s", oldHostname, newHostname, Common.DEFAULT_DOMAIN_NAME, Common.ETC_HOSTS_FILE ) ); }  RequestBuilder getRegisterManagementContainerCommand( String token ); RequestBuilder getRemoveUserIfExistsCommand( final String username ); RequestBuilder getDestroyContainerCommand( String containerName ); RequestBuilder getRemoveHostnameFromEtcHostsCommand( final HostAddresses hostAddresses );  }
@Test public void testGetChangeHostnameInEtcHostsCommand() throws Exception { assertEquals( "sed -i 's/\\bOLD\\b/NEW/g' /etc/hosts && sed -i 's/\\bOLD.intra.lan\\b/NEW.intra.lan/g' /etc/hosts", localPeerCommands.getChangeHostnameInEtcHostsCommand( "OLD", "NEW" ).build( "ID" ).getCommand() ); }