### Question:
InMemoryConnectionServiceImpl implements IConnectionService { public boolean updateConnection( IDatabaseConnection connection ) throws ConnectionServiceException { IDatabaseConnection conn = getConnectionByName( connection.getName() ); if ( conn != null ) { conn.setAccessType( connection.getAccessType() ); conn.setPassword( connection.getPassword() ); conn.setUsername( connection.getUsername() ); return true; } else { logger.error( Messages.getErrorString( "ConnectionServiceInMemoryDelegate.ERROR_0005_UNABLE_TO_UPDATE_CONNECTION", connection.getName(), null ) ); throw new ConnectionServiceException( Messages .getErrorString( "ConnectionServiceInMemoryDelegate.ERROR_0005_UNABLE_TO_UPDATE_CONNECTION", connection.getName(), null ) ); } } InMemoryConnectionServiceImpl(); List<IDatabaseConnection> getConnections(); IDatabaseConnection getConnectionByName( String name ); boolean addConnection( IDatabaseConnection connection ); boolean updateConnection( IDatabaseConnection connection ); boolean deleteConnection( IDatabaseConnection connection ); boolean deleteConnection( String name ); boolean testConnection( IDatabaseConnection connection ); boolean isConnectionExist( String connectionName );  }### Answer:
@Test public void testUpdateConnection() { try { InMemoryConnectionServiceImpl serv = new InMemoryConnectionServiceImpl(); List<IDatabaseConnection> conns = serv.getConnections(); assertTrue( conns != null && conns.size() == 0 ); IDatabaseConnection connection = new DatabaseConnection(); connection.setName( "Connection 1" ); connection.setUsername( "admin" ); connection.setPassword( "password" ); serv.addConnection( connection ); conns = serv.getConnections(); assertTrue( conns.get( 0 ).getUsername().equals( "admin" ) ); assertTrue( conns.get( 0 ).getPassword().equals( "password" ) ); connection = new DatabaseConnection(); connection.setName( "Connection 1" ); connection.setUsername( "root" ); connection.setPassword( "pass" ); serv.updateConnection( connection ); List<IDatabaseConnection> conns1 = serv.getConnections(); assertTrue( conns1 != null && conns1.size() > 0 ); assertTrue( conns1.size() == conns.size() ); assertTrue( conns1.get( 0 ).getUsername().equals( "root" ) ); assertTrue( conns1.get( 0 ).getPassword().equals( "pass" ) ); } catch ( Exception ex ) { fail(); } }