@Test
public void addAndUpdateAndDeleteRemoteRepository()
throws Exception
{
RemoteRepositoriesService service = getRemoteRepositoriesService();
WebClient.client( service ).header( "Authorization", authorizationHeader );
int initialSize = service.getRemoteRepositories().size();
service.addRemoteRepository( getRemoteRepository() );
assertNotNull( service.getRemoteRepository( "id-new" ) );
assertEquals( getRemoteRepository().getName(), service.getRemoteRepository( "id-new" ).getName() );
assertEquals( getRemoteRepository().getUrl(), service.getRemoteRepository( "id-new" ).getUrl() );
assertEquals( getRemoteRepository().getLayout(), service.getRemoteRepository( "id-new" ).getLayout() );
assertEquals( getRemoteRepository().getUserName(), service.getRemoteRepository( "id-new" ).getUserName() );
assertEquals( getRemoteRepository().getPassword(), service.getRemoteRepository( "id-new" ).getPassword() );
assertEquals( getRemoteRepository().getTimeout(), service.getRemoteRepository( "id-new" ).getTimeout() );
assertEquals( initialSize + 1, service.getRemoteRepositories().size() );
RemoteRepository repo = getRemoteRepository();
repo.setName( "name changed" );
repo.setPassword( "new password" );
repo.setUserName( "new username" );
repo.setUrl( "http://foo.new.org" );
service.updateRemoteRepository( repo );
assertEquals( repo.getName(), service.getRemoteRepository( "id-new" ).getName() );
assertEquals( repo.getUrl(), service.getRemoteRepository( "id-new" ).getUrl() );
assertEquals( repo.getLayout(), service.getRemoteRepository( "id-new" ).getLayout() );
assertEquals( repo.getUserName(), service.getRemoteRepository( "id-new" ).getUserName() );
assertEquals( repo.getPassword(), service.getRemoteRepository( "id-new" ).getPassword() );
assertEquals( repo.getTimeout(), service.getRemoteRepository( "id-new" ).getTimeout() );
service.deleteRemoteRepository( "id-new" );
assertNull( service.getRemoteRepository( "id-new" ) );
assertEquals( initialSize, service.getRemoteRepositories().size() );
}