### Question:
ConnectionServiceConcrete { public boolean updateConnection( DatabaseConnection connection ) throws ConnectionServiceException { applySavedPassword( connection ); return service.updateConnection( connection ); } ConnectionServiceConcrete(); List<DatabaseConnection> getConnections(); DatabaseConnection getConnectionByName( String name ); boolean addConnection( DatabaseConnection connection ); boolean updateConnection( DatabaseConnection connection ); boolean deleteConnection( DatabaseConnection connection ); boolean deleteConnectionByName( String name ); boolean testConnection( DatabaseConnection connection ); boolean isConnectionExist( String connectionName );  }### Answer:
@Test public void testUpdateConnection() throws Exception { String pass = "pass"; when( iConnection.getPassword() ).thenReturn( pass ); when( service.updateConnection( any( IDatabaseConnection.class ) ) ).thenReturn( true ); when( service.getConnectionById( anyString() ) ).thenReturn( iConnection ); when( connection.getPassword() ).thenReturn( "" ); when( connection.getId() ).thenReturn( "" ); concrete.updateConnection( connection ); verify( connection ).setPassword( eq( pass ) ); }