@Test
  public void newServiceInstanceBindingCreatedSuccessfully()
      throws ServiceBrokerException, ServiceInstanceBindingExistsException {

    when(admin.getCredentialsFromSensors(
            anyString(),
            any(Predicate.class),
            any(Predicate.class),
            any(Predicate.class),
            any(Predicate.class)))
        .thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap()));
    when(admin.hasEffector(anyString(), anyString(), anyString()))
        .thenReturn(new AsyncResult<>(false));
    when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
    when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of());
    when(brooklynCatalogService.getServiceDefinition(anyString())).thenReturn(serviceDefinition);
    CreateServiceInstanceBindingRequest request =
        new CreateServiceInstanceBindingRequest(
            serviceInstance.getServiceDefinitionId(), "planId", "appGuid");
    ServiceInstanceBinding binding =
        bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));

    assertNotNull(binding);
    assertEquals(SVC_INST_BIND_ID, binding.getId());
  }
  @Test
  public void newServiceInstanceBindingCreatedSuccessfullyWithBindEffector()
      throws ServiceBrokerException, ServiceInstanceBindingExistsException, PollingException {
    when(admin.getRestApi()).thenReturn(brooklynApi);
    when(admin.getCredentialsFromSensors(
            anyString(),
            any(Predicate.class),
            any(Predicate.class),
            any(Predicate.class),
            any(Predicate.class)))
        .thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap()));
    when(admin.hasEffector(anyString(), anyString(), anyString()))
        .thenReturn(new AsyncResult<>(true));
    when(admin.invokeEffector(anyString(), anyString(), anyString(), anyString(), anyMap()))
        .thenReturn(new AsyncResult<>(TASK_RESPONSE_INCOMPLETE));
    when(brooklynApi.getActivityApi()).thenReturn(activityApi);
    when(activityApi.get(anyString()))
        .thenReturn(TASK_SUMMARY_INCOMPLETE)
        .thenReturn(TASK_SUMMARY_INCOMPLETE)
        .thenReturn(TASK_SUMMARY_INCOMPLETE)
        .thenReturn(TASK_SUMMARY_INCOMPLETE)
        .thenReturn(TASK_SUMMARY_COMPLETE);
    doCallRealMethod().when(admin).blockUntilTaskCompletes(anyString());
    doCallRealMethod().when(admin).blockUntilTaskCompletes(anyString(), any(Duration.class));
    when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
    when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of());
    when(brooklynCatalogService.getServiceDefinition(anyString())).thenReturn(serviceDefinition);
    CreateServiceInstanceBindingRequest request =
        new CreateServiceInstanceBindingRequest(
            serviceInstance.getServiceDefinitionId(), "planId", "appGuid");
    ServiceInstanceBinding binding =
        bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));

    assertNotNull(binding);
    assertEquals(SVC_INST_BIND_ID, binding.getId());
  }