Program: 47579
Project: 47579
Buggy source:
@Test public void testAddDomainToRepository() throws Exception {
  final MockUnifiedRepository repository=new MockUnifiedRepository();
  final PentahoMetadataDomainRepositoryBackend backend=new PentahoMetadataDomainRepositoryBackend(repository);
  backend.setXmiParser(new MockXmiParser());
  try {
    backend.addDomainToRepository(null);
    fail();
  }
 catch (  Exception success) {
  }
  try {
    backend.addDomainToRepository(new MockDomain(null));
    fail();
  }
 catch (  Exception success) {
  }
  try {
    backend.addDomainToRepository(new MockDomain("String_Node_Str"));
    fail();
  }
 catch (  Exception success) {
  }
  repository.createFolder("String_Node_Str");
  repository.createFolder("String_Node_Str");
  repository.getFileTable().put(METADATA_INFO.getMetadataMappingFilePath(),SAMPLE_PROPERTIES_FILE);
  assertEquals(3,repository.getFileTable().size());
  backend.addDomainToRepository(new MockDomain("String_Node_Str"));
  assertEquals(5,repository.getFileTable().size());
}

Fixed version (ground truth):
@Test public void testAddDomainToRepository() throws Exception {
  final MockUnifiedRepository repository=new MockUnifiedRepository();
  final PentahoMetadataDomainRepositoryBackend backend=new PentahoMetadataDomainRepositoryBackend(repository);
  backend.setXmiParser(new MockXmiParser());
  try {
    backend.addDomainToRepository(null);
    fail();
  }
 catch (  Exception success) {
  }
  try {
    backend.addDomainToRepository(new MockDomain(null));
    fail();
  }
 catch (  Exception success) {
  }
  try {
    backend.addDomainToRepository(new MockDomain("String_Node_Str"));
    fail();
  }
 catch (  Exception success) {
  }
  repository.createFolder("String_Node_Str");
  repository.createFolder("String_Node_Str");
  repository.getFileTable().put(METADATA_INFO.getMetadataMappingFilePath(),SAMPLE_PROPERTIES_FILE);
  assertEquals(3,repository.getFileTable().size());
  final String domainId="String_Node_Str";
  final MockDomain mockDomain=new MockDomain(domainId);
  backend.addDomainToRepository(mockDomain);
  assertEquals(5,repository.getFileTable().size());
  Properties properties=(Properties)repository.getFileTable().get(METADATA_INFO.getMetadataMappingFilePath());
  final String loc=properties.getProperty(domainId);
  assertNotNull(loc);
  final String expectedPath=METADATA_INFO.getMetadataFolderPath() + "String_Node_Str" + domainId+ "String_Node_Str"+ METADATA_INFO.getMetadataFilename();
  assertEquals(expectedPath,loc);
  final Map<String,RepositoryFile> repositoryFileMap1=backend.loadDomainMappingFromRepository();
  assertNotNull(repositoryFileMap1);
  assertNotNull(repositoryFileMap1.containsKey(domainId));
  assertEquals(expectedPath,repositoryFileMap1.get(domainId).getPath());
  final Domain domain1=backend.loadDomain(domainId,repositoryFileMap1.get(domainId));
  assertNotNull(domain1);
  backend.setXmiParser(new AlteredMockXmiParser());
  backend.addDomainToRepository(mockDomain);
  final Map<String,RepositoryFile> repositoryFileMap2=backend.loadDomainMappingFromRepository();
  final Domain domain2=backend.loadDomain(domainId,repositoryFileMap2.get(domainId));
  assertEquals(domain1.getId(),domain2.getId());
  assertNotSame(domain1,domain2);
}