@BeforeClass
  public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    Services.get().register(new ProxyUserService());
    Services.get().register(new GroupsService());
    groupsService = Services.get().getService(GroupsService.SERVICE_NAME);
    proxyUserService = Services.get().getService(ProxyUserService.SERVICE_NAME);
    groupsService.init();

    RuntimeProperties.get().setProperty("falcon.service.ProxyUserService.proxyuser.foo.hosts", "*");
    RuntimeProperties.get()
        .setProperty("falcon.service.ProxyUserService.proxyuser.foo.groups", "*");
    proxyUserService.init();
  }
  @Override
  public void init() throws FalconException {
    graph = initializeGraphDB();
    createIndicesForVertexKeys();
    // todo - create Edge Cardinality Constraints
    LOG.info("Initialized graph db: {}", graph);

    vertexIndexedKeys = getIndexableGraph().getIndexedKeys(Vertex.class);
    LOG.info("Init vertex property keys: {}", vertexIndexedKeys);

    edgeIndexedKeys = getIndexableGraph().getIndexedKeys(Edge.class);
    LOG.info("Init edge property keys: {}", edgeIndexedKeys);

    boolean preserveHistory =
        Boolean.valueOf(
            StartupProperties.get().getProperty("falcon.graph.preserve.history", "false"));
    entityGraphBuilder = new EntityRelationshipGraphBuilder(graph, preserveHistory);
    instanceGraphBuilder = new InstanceRelationshipGraphBuilder(graph, preserveHistory);

    ConfigurationStore.get().registerListener(this);
    Services.get()
        .<WorkflowJobEndNotificationService>getService(
            WorkflowJobEndNotificationService.SERVICE_NAME)
        .registerListener(this);
    try {
      transactionRetries =
          Integer.parseInt(
              StartupProperties.get().getProperty("falcon.graph.transaction.retry.count", "3"));
      transactionRetryDelayInMillis =
          Long.parseLong(
              StartupProperties.get().getProperty("falcon.graph.transaction.retry.delay", "5"));
    } catch (NumberFormatException e) {
      throw new FalconException("Invalid values for graph transaction retry delay/count " + e);
    }
  }
  @Override
  public void destroy() throws FalconException {
    Services.get()
        .<WorkflowJobEndNotificationService>getService(
            WorkflowJobEndNotificationService.SERVICE_NAME)
        .unregisterListener(this);

    LOG.info("Shutting down graph db");
    graph.shutdown();
  }
 private void registerServices() throws FalconException {
   mockTimeService = Mockito.mock(AlarmService.class);
   Mockito.when(mockTimeService.getName()).thenReturn("AlarmService");
   Mockito.when(
           mockTimeService.createRequestBuilder(
               Mockito.any(NotificationHandler.class), Mockito.any(ID.class)))
       .thenCallRealMethod();
   mockDataService = Mockito.mock(DataAvailabilityService.class);
   Mockito.when(mockDataService.getName()).thenReturn("DataAvailabilityService");
   Mockito.when(
           mockDataService.createRequestBuilder(
               Mockito.any(NotificationHandler.class), Mockito.any(ID.class)))
       .thenCallRealMethod();
   dagEngine = Mockito.mock(OozieDAGEngine.class);
   Mockito.doNothing().when(dagEngine).resume(Mockito.any(ExecutionInstance.class));
   mockSchedulerService = Mockito.mock(SchedulerService.class);
   Mockito.when(mockSchedulerService.getName()).thenReturn("JobSchedulerService");
   StartupProperties.get().setProperty("dag.engine.impl", MockDAGEngine.class.getName());
   StartupProperties.get()
       .setProperty("execution.service.impl", FalconExecutionService.class.getName());
   dagEngine = Mockito.spy(DAGEngineFactory.getDAGEngine("testCluster"));
   Mockito.when(
           mockSchedulerService.createRequestBuilder(
               Mockito.any(NotificationHandler.class), Mockito.any(ID.class)))
       .thenCallRealMethod();
   mockCompletionService = Mockito.mock(JobCompletionService.class);
   Mockito.when(mockCompletionService.getName()).thenReturn("JobCompletionService");
   Mockito.when(
           mockCompletionService.createRequestBuilder(
               Mockito.any(NotificationHandler.class), Mockito.any(ID.class)))
       .thenCallRealMethod();
   Services.get().register(mockTimeService);
   Services.get().register(mockDataService);
   Services.get().register(mockSchedulerService);
   Services.get().register(mockCompletionService);
 }
  @BeforeClass
  public void setUp() throws Exception {
    CurrentUser.authenticate(FALCON_USER);

    configStore = ConfigurationStore.get();

    Services.get().register(new WorkflowJobEndNotificationService());
    StartupProperties.get()
        .setProperty(
            "falcon.graph.storage.directory", "target/graphdb-" + System.currentTimeMillis());
    StartupProperties.get().setProperty("falcon.graph.preserve.history", "true");
    service = new MetadataMappingService();
    service.init();

    Set<String> vertexPropertyKeys = service.getVertexIndexedKeys();
    System.out.println("Got vertex property keys: " + vertexPropertyKeys);

    Set<String> edgePropertyKeys = service.getEdgeIndexedKeys();
    System.out.println("Got edge property keys: " + edgePropertyKeys);
  }
 @AfterClass
 public void tearDown() throws Exception {
   proxyUserService.destroy();
   groupsService.destroy();
   Services.get().reset();
 }