Program: 5040
Project: 5040
Buggy source:
@Test public void test() throws Exception {
  final Principal systemUser=new Principal(UserGroupInformation.getCurrentUser().getShortUserName(),Principal.PrincipalType.USER);
  Predicate<EntityId> systemUserFilter=authorizationEnforcer.createFilter(systemUser);
  Predicate<EntityId> adminUserFilter=authorizationEnforcer.createFilter(ADMIN_USER);
  Assert.assertFalse(systemUserFilter.apply(instanceId));
  Assert.assertFalse(systemUserFilter.apply(NamespaceId.SYSTEM));
  Assert.assertFalse(adminUserFilter.apply(NamespaceId.DEFAULT));
  authorizationBootstrapper.run();
  Tasks.waitFor(true,new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      Predicate<EntityId> systemUserFilter=authorizationEnforcer.createFilter(systemUser);
      Predicate<EntityId> adminUserFilter=authorizationEnforcer.createFilter(ADMIN_USER);
      return systemUserFilter.apply(instanceId) && systemUserFilter.apply(NamespaceId.SYSTEM) && adminUserFilter.apply(NamespaceId.DEFAULT);
    }
  }
,10,TimeUnit.SECONDS);
  txManager.startAndWait();
  datasetService.startAndWait();
  waitForService(Constants.Service.DATASET_MANAGER);
  defaultNamespaceEnsurer.startAndWait();
  systemArtifactLoader.startAndWait();
  waitForService(defaultNamespaceEnsurer);
  waitForService(systemArtifactLoader);
  Tasks.waitFor(true,new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      try {
        return namespaceQueryAdmin.exists(NamespaceId.DEFAULT);
      }
 catch (      Exception e) {
        return false;
      }
    }
  }
,10,TimeUnit.SECONDS);
  Assert.assertTrue(defaultNamespaceEnsurer.isRunning());
  Tasks.waitFor(true,new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      try {
        artifactRepository.getArtifact(SYSTEM_ARTIFACT.toId());
        return true;
      }
 catch (      Exception e) {
        return false;
      }
    }
  }
,20,TimeUnit.SECONDS);
  Assert.assertTrue(systemArtifactLoader.isRunning());
  Dataset systemDataset=DatasetsUtil.getOrCreateDataset(dsFramework,NamespaceId.SYSTEM.dataset("String_Node_Str"),Table.class.getName(),DatasetProperties.EMPTY,Collections.<String,String>emptyMap(),this.getClass().getClassLoader());
  Assert.assertNotNull(systemDataset);
  SecurityRequestContext.setUserId(ADMIN_USER.getName());
  namespaceAdmin.create(new NamespaceMeta.Builder().setName("String_Node_Str").build());
  SecurityRequestContext.setUserId("String_Node_Str");
  try {
    namespaceAdmin.create(new NamespaceMeta.Builder().setName("String_Node_Str").build());
    Assert.fail("String_Node_Str");
  }
 catch (  UnauthorizedException expected) {
  }
}

Fixed version (ground truth):
@Test public void test() throws Exception {
  final Principal systemUser=new Principal(UserGroupInformation.getCurrentUser().getShortUserName(),Principal.PrincipalType.USER);
  Predicate<EntityId> systemUserFilter=authorizationEnforcer.createFilter(systemUser);
  Predicate<EntityId> adminUserFilter=authorizationEnforcer.createFilter(ADMIN_USER);
  Assert.assertFalse(systemUserFilter.apply(instanceId));
  Assert.assertFalse(systemUserFilter.apply(NamespaceId.SYSTEM));
  Assert.assertFalse(adminUserFilter.apply(NamespaceId.DEFAULT));
  authorizationBootstrapper.run();
  Tasks.waitFor(true,new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      Predicate<EntityId> systemUserFilter=authorizationEnforcer.createFilter(systemUser);
      Predicate<EntityId> adminUserFilter=authorizationEnforcer.createFilter(ADMIN_USER);
      return systemUserFilter.apply(instanceId) && systemUserFilter.apply(NamespaceId.SYSTEM) && adminUserFilter.apply(NamespaceId.DEFAULT);
    }
  }
,10,TimeUnit.SECONDS);
  txManager.startAndWait();
  datasetService.startAndWait();
  waitForService(Constants.Service.DATASET_MANAGER);
  defaultNamespaceEnsurer.startAndWait();
  systemArtifactLoader.startAndWait();
  waitForService(defaultNamespaceEnsurer);
  waitForService(systemArtifactLoader);
  Tasks.waitFor(true,new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      try {
        return namespaceQueryAdmin.exists(NamespaceId.DEFAULT);
      }
 catch (      Exception e) {
        return false;
      }
    }
  }
,10,TimeUnit.SECONDS);
  Assert.assertTrue(defaultNamespaceEnsurer.isRunning());
  Tasks.waitFor(true,new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      try {
        artifactRepository.getArtifact(SYSTEM_ARTIFACT.toId());
        return true;
      }
 catch (      Exception e) {
        return false;
      }
    }
  }
,20,TimeUnit.SECONDS);
  Assert.assertTrue(systemArtifactLoader.isRunning());
  Dataset systemDataset=DatasetsUtil.getOrCreateDataset(dsFramework,NamespaceId.SYSTEM.dataset("String_Node_Str"),Table.class.getName(),DatasetProperties.EMPTY,Collections.<String,String>emptyMap());
  Assert.assertNotNull(systemDataset);
  SecurityRequestContext.setUserId(ADMIN_USER.getName());
  namespaceAdmin.create(new NamespaceMeta.Builder().setName("String_Node_Str").build());
  SecurityRequestContext.setUserId("String_Node_Str");
  try {
    namespaceAdmin.create(new NamespaceMeta.Builder().setName("String_Node_Str").build());
    Assert.fail("String_Node_Str");
  }
 catch (  UnauthorizedException expected) {
  }
}