test_class.declarator: thrown= ExpectedException.none()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public ExpectedException thrown= ExpectedException.none();
test_class.type: ExpectedException
test_class.var_name: thrown
test_class.declarator: remoteRegistrations
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected RemoteRegistrations remoteRegistrations;
test_class.type: RemoteRegistrations
test_class.var_name: remoteRegistrations
test_class.declarator: registrationsRepository
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected RegistrationsRepository registrationsRepository;
test_class.type: RegistrationsRepository
test_class.var_name: registrationsRepository
test_class.declarator: localRegistrations
test_class.modifier: @Autowired
      @InjectMocks
      protected
test_class.original_string: @Autowired
      @InjectMocks
      protected LocalRegistrations localRegistrations;
test_class.type: LocalRegistrations
test_class.var_name: localRegistrations
test_class.file: cepheus-broker/src/test/java/com/orange/cepheus/broker/LocalRegistrationsTest.java
test_class.identifier: LocalRegistrationsTest
test_case.body: @Test
      public void testRegistrationBadDuration() throws Exception {
          RegisterContext registerContext = createRegistrationContext();
          registerContext.setDuration("PIPO");
  
          //TODO expect does not work on inner Exception
          try {
              localRegistrations.updateRegistrationContext(registerContext);
              fail("registration should fail on bad duration with RegistrationException");
          } catch (RegistrationException ex) {
          }
  
          verify(remoteRegistrations, never()).registerContext(any(), any());
      }
test_case.class_method_signature: LocalRegistrationsTest.testRegistrationBadDuration()
test_case.full_signature: @Test public void testRegistrationBadDuration()
test_case.identifier: testRegistrationBadDuration
test_case.invocations: createRegistrationContext setDuration updateRegistrationContext fail registerContext verify never any any
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRegistrationBadDuration()
focal_class.declarator: logger = LoggerFactory.getLogger(LocalRegistrations.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = LoggerFactory.getLogger(LocalRegistrations.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: remoteRegistrations
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected RemoteRegistrations remoteRegistrations;
focal_class.type: RemoteRegistrations
focal_class.var_name: remoteRegistrations
focal_class.declarator: patterns
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private Patterns patterns;
focal_class.type: Patterns
focal_class.var_name: patterns
focal_class.declarator: registrationsRepository
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected RegistrationsRepository registrationsRepository;
focal_class.type: RegistrationsRepository
focal_class.var_name: registrationsRepository
focal_class.declarator: registrations = new ConcurrentHashMap<>()
focal_class.original_string: Map<String, Registration> registrations = new ConcurrentHashMap<>();
focal_class.type: Map<String, Registration>
focal_class.var_name: registrations
focal_class.file: cepheus-broker/src/main/java/com/orange/cepheus/broker/LocalRegistrations.java
focal_class.identifier: LocalRegistrations
focal_class.class_method_signature: LocalRegistrations.updateRegistrationContext(RegisterContext registerContext)
focal_class.full_signature: public String updateRegistrationContext(RegisterContext registerContext)
focal_class.identifier: updateRegistrationContext
focal_class.modifiers: public
focal_class.parameters: (RegisterContext registerContext)
focal_class.return: String
focal_class.signature: String updateRegistrationContext(RegisterContext registerContext)
focal_class.class_method_signature: LocalRegistrations.getRegistration(String registrationId)
focal_class.full_signature: public Registration getRegistration(String registrationId)
focal_class.identifier: getRegistration
focal_class.modifiers: public
focal_class.parameters: (String registrationId)
focal_class.return: Registration
focal_class.signature: Registration getRegistration(String registrationId)
focal_class.class_method_signature: LocalRegistrations.findProvidingApplication(EntityId searchEntityId, Set<String> searchAttributes)
focal_class.full_signature: public Iterator<URI> findProvidingApplication(EntityId searchEntityId, Set<String> searchAttributes)
focal_class.identifier: findProvidingApplication
focal_class.modifiers: public
focal_class.parameters: (EntityId searchEntityId, Set<String> searchAttributes)
focal_class.return: Iterator<URI>
focal_class.signature: Iterator<URI> findProvidingApplication(EntityId searchEntityId, Set<String> searchAttributes)
focal_class.class_method_signature: LocalRegistrations.allContextRegistrationAttributes(ContextRegistration contextRegistration)
focal_class.full_signature: private Collection<String> allContextRegistrationAttributes(ContextRegistration contextRegistration)
focal_class.identifier: allContextRegistrationAttributes
focal_class.modifiers: private
focal_class.parameters: (ContextRegistration contextRegistration)
focal_class.return: Collection<String>
focal_class.signature: Collection<String> allContextRegistrationAttributes(ContextRegistration contextRegistration)
focal_class.class_method_signature: LocalRegistrations.purgeExpiredContextRegistrations()
focal_class.full_signature: @Scheduled(fixedDelay = 60000) public void purgeExpiredContextRegistrations()
focal_class.identifier: purgeExpiredContextRegistrations
focal_class.modifiers: @Scheduled(fixedDelay = 60000) public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void purgeExpiredContextRegistrations()
focal_class.class_method_signature: LocalRegistrations.registrationDuration(RegisterContext registerContext)
focal_class.full_signature: private Duration registrationDuration(RegisterContext registerContext)
focal_class.identifier: registrationDuration
focal_class.modifiers: private
focal_class.parameters: (RegisterContext registerContext)
focal_class.return: Duration
focal_class.signature: Duration registrationDuration(RegisterContext registerContext)
focal_method.body: public String updateRegistrationContext(RegisterContext registerContext) throws RegistrationException, RegistrationPersistenceException {
          Duration duration = registrationDuration(registerContext);
          String registrationId = registerContext.getRegistrationId();
  
          // Handle a zero duration as a special remove operation
          if (duration.isZero() && registrationId != null) {
              registrationsRepository.removeRegistration(registrationId);
              registrations.remove(registrationId);
              remoteRegistrations.removeRegistration(registrationId);
              return registrationId;
          }
  
          // Compile all entity patterns now to check for conformance (result is cached for later use)
          try {
              registerContext.getContextRegistrationList().forEach(c -> c.getEntityIdList().forEach(patterns::getPattern));
          } catch (PatternSyntaxException e) {
              throw new RegistrationException("bad pattern", e);
          }
  
          // Generate a registration id if none was provided or if it does not refer to an existing registration
          if (registrationId == null || registrations.get(registrationId) == null) {
              registrationId = UUID.randomUUID().toString();
              registerContext.setRegistrationId(registrationId);
          }
  
          // Exists in database
          Instant expirationDate = Instant.now().plus(duration);
          Registration registration;
          //TODO: instead of use insert or update, use replace instruction of sqlite
          try {
              registration = registrationsRepository.getRegistration(registerContext.getRegistrationId());
              // update registration
              registration.setExpirationDate(expirationDate);
              registration.setRegisterContext(registerContext);
              registrationsRepository.updateRegistration(registration);
          } catch (EmptyResultDataAccessException e) {
              // Create registration and set the expiration date
              registration = new Registration(expirationDate, registerContext);
              registrationsRepository.saveRegistration(registration);
          }
  
          registrations.put(registrationId, registration);
  
          // Forward to remote broker
          remoteRegistrations.registerContext(registerContext, registrationId);
  
          return registrationId;
      }
focal_method.class_method_signature: LocalRegistrations.updateRegistrationContext(RegisterContext registerContext)
focal_method.full_signature: public String updateRegistrationContext(RegisterContext registerContext)
focal_method.identifier: updateRegistrationContext
focal_method.invocations: registrationDuration getRegistrationId isZero removeRegistration remove removeRegistration forEach getContextRegistrationList forEach getEntityIdList get toString randomUUID setRegistrationId plus now getRegistration getRegistrationId setExpirationDate setRegisterContext updateRegistration saveRegistration put registerContext
focal_method.modifiers: public
focal_method.parameters: (RegisterContext registerContext)
focal_method.return: String
focal_method.signature: String updateRegistrationContext(RegisterContext registerContext)