test_class.declarator: taskScheduler
test_class.modifier: @Mock
test_class.original_string: @Mock
      TaskScheduler taskScheduler;
test_class.type: TaskScheduler
test_class.var_name: taskScheduler
test_class.declarator: ngsiClient = Mockito.mock(NgsiClient.class, RETURNS_SMART_NULLS)
test_class.modifier: @Mock
test_class.original_string: @Mock
      NgsiClient ngsiClient = Mockito.mock(NgsiClient.class, RETURNS_SMART_NULLS);
test_class.type: NgsiClient
test_class.var_name: ngsiClient
test_class.declarator: subscriptionManager
test_class.modifier: @Autowired
      @InjectMocks
test_class.original_string: @Autowired
      @InjectMocks
      SubscriptionManager subscriptionManager;
test_class.type: SubscriptionManager
test_class.var_name: subscriptionManager
test_class.file: cepheus-cep/src/test/java/com/orange/cepheus/cep/SubscriptionManagerTest.java
test_class.identifier: SubscriptionManagerTest
test_case.body: @Test
      public void setConfigurationOK() throws Exception {
  
          // Mock the task scheduler and capture the runnable
          ArgumentCaptor<Runnable> runnableArg = ArgumentCaptor.forClass(Runnable.class);
          when(taskScheduler.scheduleWithFixedDelay(runnableArg.capture(), anyLong())).thenReturn(Mockito.mock(ScheduledFuture.class));
  
          // Mock the response to the subsribeContext
          ArgumentCaptor<SuccessCallback> successArg = ArgumentCaptor.forClass(SuccessCallback.class);
          ListenableFuture<SubscribeContextResponse> responseFuture = Mockito.mock(ListenableFuture.class);
          doNothing().when(responseFuture).addCallback(successArg.capture(), any());
  
          Configuration configuration = getBasicConf();
          subscriptionManager.setConfiguration(configuration);
  
          // Capture the arg of subscription and return the mocked future
          ArgumentCaptor<String> urlProviderArg = ArgumentCaptor.forClass(String.class);
          ArgumentCaptor<SubscribeContext> subscribeContextArg = ArgumentCaptor.forClass(SubscribeContext.class);
          when(ngsiClient.subscribeContext(urlProviderArg.capture(), eq(null), subscribeContextArg.capture())).thenReturn(responseFuture);
  
          // Execute scheduled runnable
          runnableArg.getValue().run();
  
          // Return the SubscribeContextResponse
          callSuccessCallback(successArg);
  
          SubscribeContext subscribeContext = subscribeContextArg.getValue();
          assertEquals("S.*", subscribeContext.getEntityIdList().get(0).getId());
          assertEquals("TempSensor", subscribeContext.getEntityIdList().get(0).getType());
          assertEquals(true, subscribeContext.getEntityIdList().get(0).getIsPattern());
          assertEquals("temp", subscribeContext.getAttributeList().get(0));
          assertEquals("PT1H", subscribeContext.getDuration());
          assertEquals("http://iotAgent", urlProviderArg.getValue());
  
          Set<Provider> providers = configuration.getEventTypeIns().get(0).getProviders();
          for(Provider provider: providers) {
              assertEquals("12345678", provider.getSubscriptionId());
              assertNotNull(provider.getSubscriptionDate());
          }
      }
test_case.class_method_signature: SubscriptionManagerTest.setConfigurationOK()
test_case.full_signature: @Test public void setConfigurationOK()
test_case.identifier: setConfigurationOK
test_case.invocations: forClass thenReturn when scheduleWithFixedDelay capture anyLong mock forClass mock addCallback when doNothing capture any getBasicConf setConfiguration forClass forClass thenReturn when subscribeContext capture eq capture run getValue callSuccessCallback getValue assertEquals getId get getEntityIdList assertEquals getType get getEntityIdList assertEquals getIsPattern get getEntityIdList assertEquals get getAttributeList assertEquals getDuration assertEquals getValue getProviders get getEventTypeIns assertEquals getSubscriptionId assertNotNull getSubscriptionDate
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void setConfigurationOK()
focal_class.declarator: logger = LoggerFactory.getLogger(SubscriptionManager.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = LoggerFactory.getLogger(SubscriptionManager.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: subscriptionPeriodicity
focal_class.modifier: @Value("${subscriptionManager.periodicity:300000}")
      private
focal_class.original_string: @Value("${subscriptionManager.periodicity:300000}")
      private long subscriptionPeriodicity;
focal_class.type: long
focal_class.var_name: subscriptionPeriodicity
focal_class.declarator: subscriptionDuration
focal_class.modifier: @Value("${subscriptionManager.duration:PT1H}")
      private
focal_class.original_string: @Value("${subscriptionManager.duration:PT1H}")
      private String subscriptionDuration;
focal_class.type: String
focal_class.var_name: subscriptionDuration
focal_class.declarator: validateSubscriptionsId
focal_class.modifier: @Value("${subscriptionManager.validateSubscriptionsId:true}")
      private
focal_class.original_string: @Value("${subscriptionManager.validateSubscriptionsId:true}")
      private boolean validateSubscriptionsId;
focal_class.type: boolean
focal_class.var_name: validateSubscriptionsId
focal_class.declarator: ngsiClient
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private NgsiClient ngsiClient;
focal_class.type: NgsiClient
focal_class.var_name: ngsiClient
focal_class.declarator: taskScheduler
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private TaskScheduler taskScheduler;
focal_class.type: TaskScheduler
focal_class.var_name: taskScheduler
focal_class.declarator: eventTypeIns = Collections.emptyList()
focal_class.modifier: private
focal_class.original_string: private List<EventTypeIn> eventTypeIns = Collections.emptyList();
focal_class.type: List<EventTypeIn>
focal_class.var_name: eventTypeIns
focal_class.declarator: subscriptions = new Subscriptions()
focal_class.modifier: private
focal_class.original_string: private Subscriptions subscriptions = new Subscriptions();
focal_class.type: Subscriptions
focal_class.var_name: subscriptions
focal_class.declarator: scheduledFuture
focal_class.modifier: private
focal_class.original_string: private ScheduledFuture scheduledFuture;
focal_class.type: ScheduledFuture
focal_class.var_name: scheduledFuture
focal_class.declarator: hostURI
focal_class.modifier: private
focal_class.original_string: private URI hostURI;
focal_class.type: URI
focal_class.var_name: hostURI
focal_class.file: cepheus-cep/src/main/java/com/orange/cepheus/cep/SubscriptionManager.java
focal_class.identifier: SubscriptionManager
focal_class.class_method_signature: SubscriptionManager.setConfiguration(Configuration configuration)
focal_class.full_signature: public void setConfiguration(Configuration configuration)
focal_class.identifier: setConfiguration
focal_class.modifiers: public
focal_class.parameters: (Configuration configuration)
focal_class.return: void
focal_class.signature: void setConfiguration(Configuration configuration)
focal_class.class_method_signature: SubscriptionManager.validateSubscriptionId(String subscriptionId, String originatorUrl)
focal_class.full_signature: public boolean validateSubscriptionId(String subscriptionId, String originatorUrl)
focal_class.identifier: validateSubscriptionId
focal_class.modifiers: public
focal_class.parameters: (String subscriptionId, String originatorUrl)
focal_class.return: boolean
focal_class.signature: boolean validateSubscriptionId(String subscriptionId, String originatorUrl)
focal_class.class_method_signature: SubscriptionManager.shutdownGracefully()
focal_class.full_signature: @PreDestroy public void shutdownGracefully()
focal_class.identifier: shutdownGracefully
focal_class.modifiers: @PreDestroy public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void shutdownGracefully()
focal_class.class_method_signature: SubscriptionManager.scheduleSubscriptionTask()
focal_class.full_signature: private void scheduleSubscriptionTask()
focal_class.identifier: scheduleSubscriptionTask
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void scheduleSubscriptionTask()
focal_class.class_method_signature: SubscriptionManager.periodicSubscriptionTask()
focal_class.full_signature: private void periodicSubscriptionTask()
focal_class.identifier: periodicSubscriptionTask
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void periodicSubscriptionTask()
focal_class.class_method_signature: SubscriptionManager.subscribeProvider(Provider provider, SubscribeContext subscribeContext, Subscriptions subscriptions)
focal_class.full_signature: private void subscribeProvider(Provider provider, SubscribeContext subscribeContext, Subscriptions subscriptions)
focal_class.identifier: subscribeProvider
focal_class.modifiers: private
focal_class.parameters: (Provider provider, SubscribeContext subscribeContext, Subscriptions subscriptions)
focal_class.return: void
focal_class.signature: void subscribeProvider(Provider provider, SubscribeContext subscribeContext, Subscriptions subscriptions)
focal_class.class_method_signature: SubscriptionManager.unsubscribeProvider(Provider provider)
focal_class.full_signature: private void unsubscribeProvider(Provider provider)
focal_class.identifier: unsubscribeProvider
focal_class.modifiers: private
focal_class.parameters: (Provider provider)
focal_class.return: void
focal_class.signature: void unsubscribeProvider(Provider provider)
focal_class.class_method_signature: SubscriptionManager.buildSubscribeContext(EventTypeIn eventType)
focal_class.full_signature: private SubscribeContext buildSubscribeContext(EventTypeIn eventType)
focal_class.identifier: buildSubscribeContext
focal_class.modifiers: private
focal_class.parameters: (EventTypeIn eventType)
focal_class.return: SubscribeContext
focal_class.signature: SubscribeContext buildSubscribeContext(EventTypeIn eventType)
focal_class.class_method_signature: SubscriptionManager.migrateSubscriptions(Configuration configuration)
focal_class.full_signature: private Subscriptions migrateSubscriptions(Configuration configuration)
focal_class.identifier: migrateSubscriptions
focal_class.modifiers: private
focal_class.parameters: (Configuration configuration)
focal_class.return: Subscriptions
focal_class.signature: Subscriptions migrateSubscriptions(Configuration configuration)
focal_class.class_method_signature: SubscriptionManager.getHeadersForProvider(Provider provider)
focal_class.full_signature: public HttpHeaders getHeadersForProvider(Provider provider)
focal_class.identifier: getHeadersForProvider
focal_class.modifiers: public
focal_class.parameters: (Provider provider)
focal_class.return: HttpHeaders
focal_class.signature: HttpHeaders getHeadersForProvider(Provider provider)
focal_method.body: public void setConfiguration(Configuration configuration) {
          hostURI = configuration.getHost();
  
          // Use a new subscription set on each new configuration
          // this prevents active subscription tasks to add subscription ids from the previous configuration
          // this will also copy the subscription information of the previous configuration to this new configuration
          subscriptions = migrateSubscriptions(configuration);
  
          // Keep a reference to configuration for next migration
          eventTypeIns = configuration.getEventTypeIns();
  
          // TODO : send unsubscribeContext with removedEventTypesIn
  
          // force launch of subscription process for new or invalid subscriptions
          scheduleSubscriptionTask();
      }
focal_method.class_method_signature: SubscriptionManager.setConfiguration(Configuration configuration)
focal_method.full_signature: public void setConfiguration(Configuration configuration)
focal_method.identifier: setConfiguration
focal_method.invocations: getHost migrateSubscriptions getEventTypeIns scheduleSubscriptionTask
focal_method.modifiers: public
focal_method.parameters: (Configuration configuration)
focal_method.return: void
focal_method.signature: void setConfiguration(Configuration configuration)