test_class.declarator: mockMvc
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private MockMvc mockMvc;
test_class.type: MockMvc
test_class.var_name: mockMvc
test_class.declarator: producerChannels
test_class.modifier: @Mock
test_class.original_string: @Mock
  	ProducerChannel producerChannels;
test_class.type: ProducerChannel
test_class.var_name: producerChannels
test_class.declarator: kafkaOperations
test_class.modifier: @Mock
test_class.original_string: @Mock
  	KafkaOps kafkaOperations;
test_class.type: KafkaOps
test_class.var_name: kafkaOperations
test_class.declarator: historyDAO
test_class.modifier: @Mock
test_class.original_string: @Mock
  	HistoryDAO historyDAO;
test_class.type: HistoryDAO
test_class.var_name: historyDAO
test_class.declarator: paramsResolver
test_class.modifier: @Mock
test_class.original_string: @Mock
  	ParamsResolver paramsResolver;
test_class.type: ParamsResolver
test_class.var_name: paramsResolver
test_class.declarator: historyService
test_class.modifier: @InjectMocks
  	@Spy
      private
test_class.original_string: @InjectMocks
  	@Spy
      private HistoryService historyService;
test_class.type: HistoryService
test_class.var_name: historyService
test_class.declarator: uri
test_class.original_string: URI uri;
test_class.type: URI
test_class.var_name: uri
test_class.declarator: temporalPayload
test_class.modifier: private
test_class.original_string: private String temporalPayload;
test_class.type: String
test_class.var_name: temporalPayload
test_class.file: History/HistoryManager/src/test/java/eu/neclab/ngsildbroker/historymanager/service/HistoryServiceTest.java
test_class.identifier: HistoryServiceTest
test_case.body: @Test
  	public void addAttrib2TemporalEntityTest() {
  		try {
  			Mockito.doReturn(true).when(historyDAO).entityExists(any());
  			historyService.addAttrib2TemporalEntity("urn:ngsi-ld:testunit:151", temporalPayload);
  			verify(kafkaOperations, times(3)).pushToKafka(any(),any(),any());
  		} catch (Exception e) {
  			Assert.fail();
  			e.printStackTrace();
  		}	
  	}
test_case.class_method_signature: HistoryServiceTest.addAttrib2TemporalEntityTest()
test_case.full_signature: @Test public void addAttrib2TemporalEntityTest()
test_case.identifier: addAttrib2TemporalEntityTest
test_case.invocations: entityExists when doReturn any addAttrib2TemporalEntity pushToKafka verify times any any any fail printStackTrace
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void addAttrib2TemporalEntityTest()
focal_class.declarator: logger = LoggerFactory.getLogger(HistoryService.class)
focal_class.modifier: private final static
focal_class.original_string: private final static Logger logger = LoggerFactory.getLogger(HistoryService.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: kafkaOperations
focal_class.modifier: @Autowired
focal_class.original_string: @Autowired
  	KafkaOps kafkaOperations;
focal_class.type: KafkaOps
focal_class.var_name: kafkaOperations
focal_class.declarator: paramsResolver
focal_class.modifier: @Autowired
focal_class.original_string: @Autowired
  	ParamsResolver paramsResolver;
focal_class.type: ParamsResolver
focal_class.var_name: paramsResolver
focal_class.declarator: historyDAO
focal_class.modifier: @Autowired
focal_class.original_string: @Autowired
  	HistoryDAO historyDAO;
focal_class.type: HistoryDAO
focal_class.var_name: historyDAO
focal_class.declarator: parser = new JsonParser()
focal_class.original_string: JsonParser parser = new JsonParser();
focal_class.type: JsonParser
focal_class.var_name: parser
focal_class.declarator: producerChannels
focal_class.modifier: private final
focal_class.original_string: private final ProducerChannel producerChannels;
focal_class.type: ProducerChannel
focal_class.var_name: producerChannels
focal_class.file: History/HistoryManager/src/main/java/eu/neclab/ngsildbroker/historymanager/service/HistoryService.java
focal_class.identifier: HistoryService
focal_class.class_method_signature: HistoryService.HistoryService(ProducerChannel producerChannels)
focal_class.full_signature: public  HistoryService(ProducerChannel producerChannels)
focal_class.identifier: HistoryService
focal_class.modifiers: public
focal_class.parameters: (ProducerChannel producerChannels)
focal_class.signature:  HistoryService(ProducerChannel producerChannels)
focal_class.class_method_signature: HistoryService.createTemporalEntityFromEntity(String payload)
focal_class.full_signature: public URI createTemporalEntityFromEntity(String payload)
focal_class.identifier: createTemporalEntityFromEntity
focal_class.modifiers: public
focal_class.parameters: (String payload)
focal_class.return: URI
focal_class.signature: URI createTemporalEntityFromEntity(String payload)
focal_class.class_method_signature: HistoryService.createTemporalEntityFromBinding(String payload)
focal_class.full_signature: public URI createTemporalEntityFromBinding(String payload)
focal_class.identifier: createTemporalEntityFromBinding
focal_class.modifiers: public
focal_class.parameters: (String payload)
focal_class.return: URI
focal_class.signature: URI createTemporalEntityFromBinding(String payload)
focal_class.class_method_signature: HistoryService.createTemporalEntity(String payload, boolean fromEntity)
focal_class.full_signature: private URI createTemporalEntity(String payload, boolean fromEntity)
focal_class.identifier: createTemporalEntity
focal_class.modifiers: private
focal_class.parameters: (String payload, boolean fromEntity)
focal_class.return: URI
focal_class.signature: URI createTemporalEntity(String payload, boolean fromEntity)
focal_class.class_method_signature: HistoryService.setCommonTemporalProperties(JsonElement jsonElement, String date, boolean fromEntity)
focal_class.full_signature: private JsonElement setCommonTemporalProperties(JsonElement jsonElement, String date, boolean fromEntity)
focal_class.identifier: setCommonTemporalProperties
focal_class.modifiers: private
focal_class.parameters: (JsonElement jsonElement, String date, boolean fromEntity)
focal_class.return: JsonElement
focal_class.signature: JsonElement setCommonTemporalProperties(JsonElement jsonElement, String date, boolean fromEntity)
focal_class.class_method_signature: HistoryService.setTemporalProperty(JsonElement jsonElement, String propertyName, String value)
focal_class.full_signature: private JsonElement setTemporalProperty(JsonElement jsonElement, String propertyName, String value)
focal_class.identifier: setTemporalProperty
focal_class.modifiers: private
focal_class.parameters: (JsonElement jsonElement, String propertyName, String value)
focal_class.return: JsonElement
focal_class.signature: JsonElement setTemporalProperty(JsonElement jsonElement, String propertyName, String value)
focal_class.class_method_signature: HistoryService.setTemporalPropertyinstanceId(JsonElement jsonElement, String propertyName, String value)
focal_class.full_signature: private JsonElement setTemporalPropertyinstanceId(JsonElement jsonElement, String propertyName, String value)
focal_class.identifier: setTemporalPropertyinstanceId
focal_class.modifiers: private
focal_class.parameters: (JsonElement jsonElement, String propertyName, String value)
focal_class.return: JsonElement
focal_class.signature: JsonElement setTemporalPropertyinstanceId(JsonElement jsonElement, String propertyName, String value)
focal_class.class_method_signature: HistoryService.pushAttributeToKafka(String entityId, String entityType, String entityCreatedAt,
  			String entityModifiedAt, String attributeId, String elementValue, Boolean createTemporalEntityIfNotExists,
  			Boolean overwriteOp)
focal_class.full_signature: private void pushAttributeToKafka(String entityId, String entityType, String entityCreatedAt,
  			String entityModifiedAt, String attributeId, String elementValue, Boolean createTemporalEntityIfNotExists,
  			Boolean overwriteOp)
focal_class.identifier: pushAttributeToKafka
focal_class.modifiers: private
focal_class.parameters: (String entityId, String entityType, String entityCreatedAt,
  			String entityModifiedAt, String attributeId, String elementValue, Boolean createTemporalEntityIfNotExists,
  			Boolean overwriteOp)
focal_class.return: void
focal_class.signature: void pushAttributeToKafka(String entityId, String entityType, String entityCreatedAt,
  			String entityModifiedAt, String attributeId, String elementValue, Boolean createTemporalEntityIfNotExists,
  			Boolean overwriteOp)
focal_class.class_method_signature: HistoryService.pushAttributeToKafka(String id, String entityModifiedAt, String attributeId, String elementValue)
focal_class.full_signature: private void pushAttributeToKafka(String id, String entityModifiedAt, String attributeId, String elementValue)
focal_class.identifier: pushAttributeToKafka
focal_class.modifiers: private
focal_class.parameters: (String id, String entityModifiedAt, String attributeId, String elementValue)
focal_class.return: void
focal_class.signature: void pushAttributeToKafka(String id, String entityModifiedAt, String attributeId, String elementValue)
focal_class.class_method_signature: HistoryService.delete(String entityId, String attributeId, String instanceId, List<Object> linkHeaders)
focal_class.full_signature: public void delete(String entityId, String attributeId, String instanceId, List<Object> linkHeaders)
focal_class.identifier: delete
focal_class.modifiers: public
focal_class.parameters: (String entityId, String attributeId, String instanceId, List<Object> linkHeaders)
focal_class.return: void
focal_class.signature: void delete(String entityId, String attributeId, String instanceId, List<Object> linkHeaders)
focal_class.class_method_signature: HistoryService.addAttrib2TemporalEntity(String entityId, String payload)
focal_class.full_signature: public void addAttrib2TemporalEntity(String entityId, String payload)
focal_class.identifier: addAttrib2TemporalEntity
focal_class.modifiers: public
focal_class.parameters: (String entityId, String payload)
focal_class.return: void
focal_class.signature: void addAttrib2TemporalEntity(String entityId, String payload)
focal_class.class_method_signature: HistoryService.modifyAttribInstanceTemporalEntity(String entityId, String payload, String attribId, String instanceId,
  			List<Object> linkHeaders)
focal_class.full_signature: public void modifyAttribInstanceTemporalEntity(String entityId, String payload, String attribId, String instanceId,
  			List<Object> linkHeaders)
focal_class.identifier: modifyAttribInstanceTemporalEntity
focal_class.modifiers: public
focal_class.parameters: (String entityId, String payload, String attribId, String instanceId,
  			List<Object> linkHeaders)
focal_class.return: void
focal_class.signature: void modifyAttribInstanceTemporalEntity(String entityId, String payload, String attribId, String instanceId,
  			List<Object> linkHeaders)
focal_class.class_method_signature: HistoryService.handleEntityCreate(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.full_signature: @KafkaListener(topics = "${entity.create.topic}", groupId = "historyManagerCreate") public void handleEntityCreate(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.identifier: handleEntityCreate
focal_class.modifiers: @KafkaListener(topics = "${entity.create.topic}", groupId = "historyManagerCreate") public
focal_class.parameters: (@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.return: void
focal_class.signature: void handleEntityCreate(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.class_method_signature: HistoryService.handleEntityAppend(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.full_signature: @KafkaListener(topics = "${entity.append.topic}", groupId = "historyManagerAppend") public void handleEntityAppend(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.identifier: handleEntityAppend
focal_class.modifiers: @KafkaListener(topics = "${entity.append.topic}", groupId = "historyManagerAppend") public
focal_class.parameters: (@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.return: void
focal_class.signature: void handleEntityAppend(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.class_method_signature: HistoryService.handleEntityUpdate(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.full_signature: @KafkaListener(topics = "${entity.update.topic}", groupId = "historyManagerUpdate") public void handleEntityUpdate(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.identifier: handleEntityUpdate
focal_class.modifiers: @KafkaListener(topics = "${entity.update.topic}", groupId = "historyManagerUpdate") public
focal_class.parameters: (@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.return: void
focal_class.signature: void handleEntityUpdate(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.class_method_signature: HistoryService.handleEntityDelete(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.full_signature: @KafkaListener(topics = "${entity.delete.topic}", groupId = "historyManagerDelete") public void handleEntityDelete(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.identifier: handleEntityDelete
focal_class.modifiers: @KafkaListener(topics = "${entity.delete.topic}", groupId = "historyManagerDelete") public
focal_class.parameters: (@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_class.return: void
focal_class.signature: void handleEntityDelete(@Payload byte[] message, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String key)
focal_method.body: public void addAttrib2TemporalEntity(String entityId, String payload) throws ResponseException, Exception {
  		logger.trace("replace attribute in temporal entity");
  		final JsonObject jsonObject = parser.parse(payload).getAsJsonObject();
  		String now = SerializationTools.formatter.format(Instant.now());
  		if (!historyDAO.entityExists(entityId)) {
  			throw new ResponseException(ErrorType.NotFound, "You cannot create an attribute on a none existing entity");
  		}
  		for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
  			logger.debug("Key = " + entry.getKey() + " Value = " + entry.getValue());
  			if (entry.getKey().equalsIgnoreCase(NGSIConstants.JSON_LD_ID)
  					|| entry.getKey().equalsIgnoreCase(NGSIConstants.JSON_LD_TYPE)
  					|| entry.getKey().equalsIgnoreCase(NGSIConstants.NGSI_LD_CREATED_AT)
  					|| entry.getKey().equalsIgnoreCase(NGSIConstants.NGSI_LD_MODIFIED_AT)) {
  				continue;
  			}
  
  			String attribId = entry.getKey();
  			if (entry.getValue().isJsonArray()) {
  				JsonArray valueArray = entry.getValue().getAsJsonArray();
  				Integer instanceCount = 0;
  				for (JsonElement jsonElement : valueArray) {
  					jsonElement = setCommonTemporalProperties(jsonElement, now, false);
  					//
  					Boolean overwriteOp = (instanceCount == 0); // if it's the first one, send the overwrite op to
  																// delete current values
  					pushAttributeToKafka(entityId, null, null, now, attribId, jsonElement.toString(), false,
  							overwriteOp);
  					instanceCount++;
  				}
  			}
  		}
  		logger.trace("attribute replaced in temporalentity " + entityId);
  	}
focal_method.class_method_signature: HistoryService.addAttrib2TemporalEntity(String entityId, String payload)
focal_method.full_signature: public void addAttrib2TemporalEntity(String entityId, String payload)
focal_method.identifier: addAttrib2TemporalEntity
focal_method.invocations: trace getAsJsonObject parse format now entityExists entrySet debug getKey getValue equalsIgnoreCase getKey equalsIgnoreCase getKey equalsIgnoreCase getKey equalsIgnoreCase getKey getKey isJsonArray getValue getAsJsonArray getValue setCommonTemporalProperties pushAttributeToKafka toString trace
focal_method.modifiers: public
focal_method.parameters: (String entityId, String payload)
focal_method.return: void
focal_method.signature: void addAttrib2TemporalEntity(String entityId, String payload)