test_class.declarator: EMPTY_FILE = "emptyFile"
test_class.modifier: public static final
test_class.original_string: public static final String EMPTY_FILE = "emptyFile";
test_class.type: String
test_class.var_name: EMPTY_FILE
test_class.declarator: tokenServices
test_class.modifier: protected
test_class.original_string: protected AgentTokenServices tokenServices;
test_class.type: AgentTokenServices
test_class.var_name: tokenServices
test_class.declarator: messageHandlerPool
test_class.modifier: protected
test_class.original_string: protected MessageHandlerPool messageHandlerPool;
test_class.type: MessageHandlerPool
test_class.var_name: messageHandlerPool
test_class.declarator: agentToken
test_class.modifier: protected
test_class.original_string: protected AgentTokenWrapper agentToken;
test_class.type: AgentTokenWrapper
test_class.var_name: agentToken
test_class.file: step-functions/step-functions-handler/src/test/java/step/functions/handler/FunctionMessageHandlerTest.java
test_class.identifier: FunctionMessageHandlerTest
test_case.body: @Test
  	public void test() throws Exception {
  		AgentTokenWrapper agentToken = getAgentToken(tokenServices);
  		
  		InputMessage message = new InputMessage();
  		
  		HashMap<String, String> properties = new HashMap<String, String>();
  
  		properties.put(FunctionMessageHandler.FUNCTION_HANDLER_PACKAGE_KEY + ".id", EMPTY_FILE);
  		properties.put(FunctionMessageHandler.FUNCTION_HANDLER_PACKAGE_KEY + ".version", "1");
  		
  		properties.put(FunctionMessageHandler.FUNCTION_HANDLER_KEY, TestFunctionHandler.class.getName());
  		
  		message.setProperties(properties);
  		
  		Input<TestInput> input = getTestInput();
  		
  		message.setPayload(new ObjectMapper().valueToTree(input));
  		
  		OutputMessage outputMessage = messageHandlerPool.get(FunctionMessageHandler.class.getName()).handle(agentToken, message);
  		Assert.assertEquals("Bonjour", outputMessage.getPayload().get("payload").get("message").asText());
  	}
test_case.class_method_signature: FunctionMessageHandlerTest.test()
test_case.full_signature: @Test public void test()
test_case.identifier: test
test_case.invocations: getAgentToken put put put getName setProperties getTestInput setPayload valueToTree handle get getName assertEquals asText get get getPayload
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test()
focal_class.declarator: FUNCTION_HANDLER_PACKAGE_KEY = "$functionhandlerjar"
focal_class.modifier: public static final
focal_class.original_string: public static final String FUNCTION_HANDLER_PACKAGE_KEY = "$functionhandlerjar";
focal_class.type: String
focal_class.var_name: FUNCTION_HANDLER_PACKAGE_KEY
focal_class.declarator: FUNCTION_HANDLER_KEY = "$functionhandler"
focal_class.modifier: public static final
focal_class.original_string: public static final String FUNCTION_HANDLER_KEY = "$functionhandler";
focal_class.type: String
focal_class.var_name: FUNCTION_HANDLER_KEY
focal_class.declarator: mapper
focal_class.modifier: private
focal_class.original_string: private ObjectMapper mapper;
focal_class.type: ObjectMapper
focal_class.var_name: mapper
focal_class.declarator: applicationContextBuilder
focal_class.modifier: private
focal_class.original_string: private ApplicationContextBuilder applicationContextBuilder;
focal_class.type: ApplicationContextBuilder
focal_class.var_name: applicationContextBuilder
focal_class.declarator: functionHandlerFactory
focal_class.modifier: public
focal_class.original_string: public FunctionHandlerFactory functionHandlerFactory;
focal_class.type: FunctionHandlerFactory
focal_class.var_name: functionHandlerFactory
focal_class.file: step-functions/step-functions-handler/src/main/java/step/functions/handler/FunctionMessageHandler.java
focal_class.identifier: FunctionMessageHandler
focal_class.class_method_signature: FunctionMessageHandler.FunctionMessageHandler()
focal_class.full_signature: public  FunctionMessageHandler()
focal_class.identifier: FunctionMessageHandler
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  FunctionMessageHandler()
focal_class.class_method_signature: FunctionMessageHandler.init(AgentTokenServices agentTokenServices)
focal_class.full_signature: @Override public void init(AgentTokenServices agentTokenServices)
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: (AgentTokenServices agentTokenServices)
focal_class.return: void
focal_class.signature: void init(AgentTokenServices agentTokenServices)
focal_class.class_method_signature: FunctionMessageHandler.handle(AgentTokenWrapper token, InputMessage inputMessage)
focal_class.full_signature: @Override public OutputMessage handle(AgentTokenWrapper token, InputMessage inputMessage)
focal_class.identifier: handle
focal_class.modifiers: @Override public
focal_class.parameters: (AgentTokenWrapper token, InputMessage inputMessage)
focal_class.return: OutputMessage
focal_class.signature: OutputMessage handle(AgentTokenWrapper token, InputMessage inputMessage)
focal_class.class_method_signature: FunctionMessageHandler.addCustomTypeToOutputMeasures(List<Measure> outputMeasures)
focal_class.full_signature: protected void addCustomTypeToOutputMeasures(List<Measure> outputMeasures)
focal_class.identifier: addCustomTypeToOutputMeasures
focal_class.modifiers: protected
focal_class.parameters: (List<Measure> outputMeasures)
focal_class.return: void
focal_class.signature: void addCustomTypeToOutputMeasures(List<Measure> outputMeasures)
focal_class.class_method_signature: FunctionMessageHandler.addAdditionalMeasuresToOutput(Output<?> output, List<Measure> additionalMeasures)
focal_class.full_signature: protected void addAdditionalMeasuresToOutput(Output<?> output, List<Measure> additionalMeasures)
focal_class.identifier: addAdditionalMeasuresToOutput
focal_class.modifiers: protected
focal_class.parameters: (Output<?> output, List<Measure> additionalMeasures)
focal_class.return: void
focal_class.signature: void addAdditionalMeasuresToOutput(Output<?> output, List<Measure> additionalMeasures)
focal_class.class_method_signature: FunctionMessageHandler.customMeasureData()
focal_class.full_signature: protected Map<String, Object> customMeasureData()
focal_class.identifier: customMeasureData
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> customMeasureData()
focal_class.class_method_signature: FunctionMessageHandler.getMergedAgentProperties(AgentTokenWrapper token)
focal_class.full_signature: private Map<String, String> getMergedAgentProperties(AgentTokenWrapper token)
focal_class.identifier: getMergedAgentProperties
focal_class.modifiers: private
focal_class.parameters: (AgentTokenWrapper token)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> getMergedAgentProperties(AgentTokenWrapper token)
focal_class.superclass: extends AbstractMessageHandler
focal_method.body: @Override
  	public OutputMessage handle(AgentTokenWrapper token, InputMessage inputMessage) throws Exception {
  		applicationContextBuilder.resetContext();
  		
  		FileVersionId functionPackage = getFileVersionId(FUNCTION_HANDLER_PACKAGE_KEY, inputMessage.getProperties());
  		if(functionPackage != null) {
  			RemoteApplicationContextFactory functionHandlerContext = new RemoteApplicationContextFactory(token.getServices().getFileManagerClient(), getFileVersionId(FUNCTION_HANDLER_PACKAGE_KEY, inputMessage.getProperties()));
  			applicationContextBuilder.pushContext(functionHandlerContext);
  		}
  		
  		return applicationContextBuilder.runInContext(()->{
  			// Merge the token and agent properties
  			Map<String, String> mergedAgentProperties = getMergedAgentProperties(token);
  			// Instantiate the function handler 
  			String handlerClass = inputMessage.getProperties().get(FUNCTION_HANDLER_KEY);
  			@SuppressWarnings("rawtypes")
  			AbstractFunctionHandler functionHandler = functionHandlerFactory.create(applicationContextBuilder.getCurrentContext().getClassLoader(), 
  					handlerClass, token.getSession(), token.getTokenReservationSession(), mergedAgentProperties);
  			
  			// Deserialize the Input from the message payload
  			JavaType javaType = mapper.getTypeFactory().constructParametrizedType(Input.class, Input.class, functionHandler.getInputPayloadClass());
  			Input<?> input = mapper.readValue(mapper.treeAsTokens(inputMessage.getPayload()), javaType);
  			
  			// Handle the input
  			MeasurementsBuilder measurementsBuilder = new MeasurementsBuilder();
  			measurementsBuilder.startMeasure(input.getFunction());
  			@SuppressWarnings("unchecked")
  			Output<?> output = functionHandler.handle(input);
  			measurementsBuilder.stopMeasure(customMeasureData());
  			
  			List<Measure> outputMeasures = output.getMeasures();
  			// Add type="custom" to all output measures
  			addCustomTypeToOutputMeasures(outputMeasures);
  			
  			// Add Keyword measure to output
  			addAdditionalMeasuresToOutput(output, measurementsBuilder.getMeasures());
  
  			// Serialize the output
  			ObjectNode outputPayload = (ObjectNode) mapper.valueToTree(output);
  
  			// Create and return the output message 
  			OutputMessageBuilder outputMessageBuilder = new OutputMessageBuilder();
  			outputMessageBuilder.setPayload(outputPayload);
  			return outputMessageBuilder.build();
  			
  		});
  	}
focal_method.class_method_signature: FunctionMessageHandler.handle(AgentTokenWrapper token, InputMessage inputMessage)
focal_method.full_signature: @Override public OutputMessage handle(AgentTokenWrapper token, InputMessage inputMessage)
focal_method.identifier: handle
focal_method.invocations: resetContext getFileVersionId getProperties getFileManagerClient getServices getFileVersionId getProperties pushContext runInContext getMergedAgentProperties get getProperties create getClassLoader getCurrentContext getSession getTokenReservationSession constructParametrizedType getTypeFactory getInputPayloadClass readValue treeAsTokens getPayload startMeasure getFunction handle stopMeasure customMeasureData getMeasures addCustomTypeToOutputMeasures addAdditionalMeasuresToOutput getMeasures valueToTree setPayload build
focal_method.modifiers: @Override public
focal_method.parameters: (AgentTokenWrapper token, InputMessage inputMessage)
focal_method.return: OutputMessage
focal_method.signature: OutputMessage handle(AgentTokenWrapper token, InputMessage inputMessage)