Program: 127316
Project: 127316
Buggy source:
/** 
 * test TDQ-6569, it should be empty String even dbMetadata.getDatabaseProductName()/dbMetadata.getDatabaseProductName() is null .
 * @throws Exception
 */
@Test public void testfillUIConnParams_DB2ZOS() throws Exception {
  java.sql.Connection sqlConnection=mock(java.sql.Connection.class);
  IMetadataConnection metadataBean=mock(IMetadataConnection.class);
  DatabaseConnection connection=mock(DatabaseConnection.class);
  EList<TaggedValue> taggedValues=new BasicEList<TaggedValue>();
  when(connection.getTaggedValue()).thenReturn(taggedValues);
  when(connection.getDatabaseType()).thenReturn("String_Node_Str");
  when(connection.getDriverClass()).thenReturn(EDatabase4DriverClassName.IBMDB2ZOS.getDriverClass());
  when(connection.isContextMode()).thenReturn(Boolean.FALSE);
  TypedReturnCode<java.sql.Connection> rc=new TypedReturnCode<java.sql.Connection>();
  rc.setOk(true);
  PowerMockito.mockStatic(MetadataConnectionUtils.class);
  when(MetadataConnectionUtils.checkConnection(metadataBean)).thenReturn(rc);
  when(MetadataConnectionUtils.isDerbyRelatedDb(anyString(),anyString())).thenReturn(false);
  DatabaseMetaData dbMetadata=mock(DatabaseMetaData.class);
  when(dbMetadata.getDatabaseProductName()).thenReturn(null);
  when(dbMetadata.getDatabaseProductName()).thenReturn(null);
  PowerMockito.mockStatic(ExtractMetaDataUtils.class);
  when(ExtractMetaDataUtils.getDatabaseMetaData(sqlConnection,connection,false)).thenReturn(dbMetadata);
  when(ExtractMetaDataUtils.getDatabaseMetaData(null,connection,false)).thenReturn(dbMetadata);
  PowerMockito.mockStatic(ConnectionUtils.class);
  ReturnCode ret=new ReturnCode();
  ret.setOk(true);
  when(ConnectionUtils.closeConnection(sqlConnection)).thenReturn(ret);
  DBConnectionFillerImpl dBConnectionFillerImp_mock=PowerMockito.spy(dBConnectionFillerImpl);
  PowerMockito.doNothing().when(dBConnectionFillerImp_mock,"String_Node_Str",metadataBean,connection);
  dBConnectionFillerImp_mock.fillUIConnParams(metadataBean,connection);
  String producetName=TaggedValueHelper.getValueString(TaggedValueHelper.DB_PRODUCT_NAME,connection);
  String version=TaggedValueHelper.getValueString(TaggedValueHelper.DB_PRODUCT_VERSION,connection);
  assertNotNull(producetName);
  assertNotNull(version);
  assertEquals(producetName,PluginConstant.EMPTY_STRING);
  assertEquals(version,PluginConstant.EMPTY_STRING);
}

Fixed version (ground truth):
/** 
 * test TDQ-6569, it should be empty String even dbMetadata.getDatabaseProductName()/dbMetadata.getDatabaseProductName() is null .
 * @throws Exception
 */
@Test public void testfillUIConnParams_DB2ZOS() throws Exception {
  java.sql.Connection sqlConnection=mock(java.sql.Connection.class);
  IMetadataConnection metadataBean=mock(IMetadataConnection.class);
  DatabaseConnection connection=mock(DatabaseConnection.class);
  EList<TaggedValue> taggedValues=new BasicEList<TaggedValue>();
  when(connection.getTaggedValue()).thenReturn(taggedValues);
  when(connection.getDatabaseType()).thenReturn("String_Node_Str");
  when(connection.getDriverClass()).thenReturn(EDatabase4DriverClassName.IBMDB2ZOS.getDriverClass());
  when(connection.isContextMode()).thenReturn(Boolean.FALSE);
  TypedReturnCode<java.sql.Connection> rc=new TypedReturnCode<java.sql.Connection>();
  rc.setOk(true);
  PowerMockito.mockStatic(MetadataConnectionUtils.class);
  when(MetadataConnectionUtils.checkConnection(metadataBean)).thenReturn(rc);
  when(MetadataConnectionUtils.isDerbyRelatedDb(anyString(),anyString())).thenReturn(false);
  DatabaseMetaData dbMetadata=mock(DatabaseMetaData.class);
  when(dbMetadata.getDatabaseProductName()).thenReturn(null);
  when(dbMetadata.getDatabaseProductName()).thenReturn(null);
  when(ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConnection,connection,false)).thenReturn(dbMetadata);
  when(ExtractMetaDataUtils.getInstance().getDatabaseMetaData(null,connection,false)).thenReturn(dbMetadata);
  PowerMockito.mockStatic(ConnectionUtils.class);
  ReturnCode ret=new ReturnCode();
  ret.setOk(true);
  when(ConnectionUtils.closeConnection(sqlConnection)).thenReturn(ret);
  DBConnectionFillerImpl dBConnectionFillerImp_mock=PowerMockito.spy(dBConnectionFillerImpl);
  PowerMockito.doNothing().when(dBConnectionFillerImp_mock,"String_Node_Str",metadataBean,connection);
  dBConnectionFillerImp_mock.fillUIConnParams(metadataBean,connection);
  String producetName=TaggedValueHelper.getValueString(TaggedValueHelper.DB_PRODUCT_NAME,connection);
  String version=TaggedValueHelper.getValueString(TaggedValueHelper.DB_PRODUCT_VERSION,connection);
  assertNotNull(producetName);
  assertNotNull(version);
  assertEquals(producetName,PluginConstant.EMPTY_STRING);
  assertEquals(version,PluginConstant.EMPTY_STRING);
}