public void setJsonResponseAsWorkflowVariable(Object responseObject, String executionId, String activitiId) throws Exception { String jsonResponse = jsonHelper.objectToJson(responseObject); setTaskWorkflowVariable(executionId, activitiId, VARIABLE_JSON_RESPONSE, jsonResponse); }
request = (T) jsonHelper.unmarshallJsonToObject(xsdClass, requestString);
JSONObject products = jsonHelper.getKeyValue(jsonObject, JSON_KEY_NAME_PRODUCTS, JSONObject.class); JSONObject current = jsonHelper.getKeyValue(products, key, JSONObject.class); String sku = jsonHelper.getKeyValue(current, JSON_KEY_NAME_SKU, String.class); JSONObject attributes = jsonHelper.getKeyValue(current, JSON_KEY_NAME_ATTRIBUTES, JSONObject.class); JSONObject terms = jsonHelper.getKeyValue(jsonObject, JSON_KEY_NAME_TERMS, JSONObject.class); JSONObject onDemand = jsonHelper.getKeyValue(terms, JSON_KEY_NAME_ON_DEMAND, JSONObject.class); JSONObject current = jsonHelper.getKeyValue(onDemand, sku, JSONObject.class); JSONObject pricingWrapper = jsonHelper.getKeyValue(current, sku + JSON_SKU_WRAPPER_SUFFIX, JSONObject.class); JSONObject priceDimensions = jsonHelper.getKeyValue(pricingWrapper, JSON_KEY_NAME_PRICE_DIMENSIONS, JSONObject.class); JSONObject innerPricingWrapper = jsonHelper.getKeyValue(priceDimensions, sku + JSON_SKU_WRAPPER_SUFFIX + JSON_PRICE_DIMENSIONS_WRAPPER_SUFFIX, JSONObject.class); JSONObject pricePerUnit = jsonHelper.getKeyValue(innerPricingWrapper, JSON_KEY_NAME_PRICE_PER_UNIT, JSONObject.class); String pricePerUnitValue = jsonHelper.getKeyValue(pricePerUnit, JSON_PRICE_PER_UNIT_WRAPPER, String.class);
StoragePolicySelection storagePolicySelection = jsonHelper.unmarshallJsonToObject(StoragePolicySelection.class, payload); jsonHelper.objectToJson(storagePolicySelection.getBusinessObjectDataKey()), jsonHelper.objectToJson(storagePolicySelection.getStoragePolicyKey()), storagePolicySelection.getStoragePolicyVersion());
@Test public void testUnmarshallJsonToListOfObjects() throws IOException { assertEquals(Arrays.asList(STRING_VALUE, STRING_VALUE_2), jsonHelper.unmarshallJsonToListOfObjects(String.class, String.format("[\"%s\",\"%s\"]", STRING_VALUE, STRING_VALUE_2))); }
@Bean public JsonHelper jsonHelper() { return new JsonHelper(); }
StoragePolicySelection storagePolicySelection = jsonHelper.unmarshallJsonToObject(StoragePolicySelection.class, payload); jsonHelper.objectToJson(storagePolicySelection.getBusinessObjectDataKey()), jsonHelper.objectToJson(storagePolicySelection.getStoragePolicyKey()), storagePolicySelection.getStoragePolicyVersion());
messageHeaders = jsonHelper.unmarshallJsonToListOfObjects(MessageHeader.class, notificationMessageEntity.getMessageHeaders());
@Bean public JsonHelper jsonHelper() { return new JsonHelper(); }
public void setJsonResponseAsWorkflowVariable(Object responseObject, String executionId, String activitiId) throws Exception { String jsonResponse = jsonHelper.objectToJson(responseObject); setTaskWorkflowVariable(executionId, activitiId, VARIABLE_JSON_RESPONSE, jsonResponse); }
final Map<String, String> fieldsBoostsMap = jsonHelper.unmarshallJsonToObject(Map.class, fieldsBoostsJsonString);
JSONObject products = jsonHelper.getKeyValue(jsonObject, JSON_KEY_NAME_PRODUCTS, JSONObject.class); JSONObject current = jsonHelper.getKeyValue(products, key, JSONObject.class); String sku = jsonHelper.getKeyValue(current, JSON_KEY_NAME_SKU, String.class); JSONObject attributes = jsonHelper.getKeyValue(current, JSON_KEY_NAME_ATTRIBUTES, JSONObject.class); JSONObject terms = jsonHelper.getKeyValue(jsonObject, JSON_KEY_NAME_TERMS, JSONObject.class); JSONObject onDemand = jsonHelper.getKeyValue(terms, JSON_KEY_NAME_ON_DEMAND, JSONObject.class); JSONObject current = jsonHelper.getKeyValue(onDemand, sku, JSONObject.class); JSONObject pricingWrapper = jsonHelper.getKeyValue(current, sku + JSON_SKU_WRAPPER_SUFFIX, JSONObject.class); JSONObject priceDimensions = jsonHelper.getKeyValue(pricingWrapper, JSON_KEY_NAME_PRICE_DIMENSIONS, JSONObject.class); JSONObject innerPricingWrapper = jsonHelper.getKeyValue(priceDimensions, sku + JSON_SKU_WRAPPER_SUFFIX + JSON_PRICE_DIMENSIONS_WRAPPER_SUFFIX, JSONObject.class); JSONObject pricePerUnit = jsonHelper.getKeyValue(innerPricingWrapper, JSON_KEY_NAME_PRICE_PER_UNIT, JSONObject.class); String pricePerUnitValue = jsonHelper.getKeyValue(pricePerUnit, JSON_PRICE_PER_UNIT_WRAPPER, String.class);
messageHeaders = jsonHelper.unmarshallJsonToListOfObjects(MessageHeader.class, notificationMessageEntity.getMessageHeaders());
/** * Sets a JSON response object as a workflow variable. * * @param responseObject the JSON object. * @param execution the delegate execution. * * @throws Exception if any problems were encountered. */ public void setJsonResponseAsWorkflowVariable(Object responseObject, DelegateExecution execution) throws Exception { String jsonResponse = jsonHelper.objectToJson(responseObject); setTaskWorkflowVariable(execution, VARIABLE_JSON_RESPONSE, jsonResponse); }
final Map<String, String> fieldsBoostsMap = jsonHelper.unmarshallJsonToObject(Map.class, fieldsBoostsJsonString);
when(jsonHelper.getKeyValue(jsonObject, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_PRODUCTS, JSONObject.class)).thenReturn(products); when(jsonHelper.getKeyValue(products, EC2_PRODUCT_KEY, JSONObject.class)).thenReturn(product); when(jsonHelper.getKeyValue(product, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_SKU, String.class)).thenReturn(SKU); when(jsonHelper.getKeyValue(product, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_ATTRIBUTES, JSONObject.class)).thenReturn(attributes); verify(jsonHelper).getKeyValue(jsonObject, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_PRODUCTS, JSONObject.class); verify(jsonHelper).getKeyValue(products, EC2_PRODUCT_KEY, JSONObject.class); verify(jsonHelper).getKeyValue(product, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_SKU, String.class); verify(jsonHelper).getKeyValue(product, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_ATTRIBUTES, JSONObject.class); verifyNoMoreInteractionsHelper();
/** * Returns a representation of a set of aggregations from the nested aggregation. This method also validates that the retrieved object is not null. * * @param nestedAggregation the nested aggregation * @param searchResponse the response of the search request * * @return the aggregations */ protected Aggregations getAggregationsFromNestedAggregation(Nested nestedAggregation, SearchResponse searchResponse) { // Retrieve the aggregations. Aggregations aggregations = nestedAggregation.getAggregations(); // Fail if the retrieved object is null. if (aggregations == null) { // Log the error along with the nested aggregation contents. LOGGER.error("Failed to retrieve aggregations from the nested aggregation. searchResponse={} nestedAggregation={}", jsonHelper.objectToJson(searchResponse), jsonHelper.objectToJson(nestedAggregation)); // Throw an exception. throw new IllegalStateException("Invalid search result."); } return aggregations; }
request = (T) jsonHelper.unmarshallJsonToObject(xsdClass, requestString);
when(jsonHelper.getKeyValue(jsonObject, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_PRODUCTS, JSONObject.class)).thenReturn(products); when(jsonHelper.getKeyValue(products, EC2_PRODUCT_KEY, JSONObject.class)).thenReturn(product); when(jsonHelper.getKeyValue(product, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_SKU, String.class)).thenReturn(SKU); when(jsonHelper.getKeyValue(product, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_ATTRIBUTES, JSONObject.class)).thenReturn(attributes); when(jsonHelper.getKeyValue(jsonObject, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_TERMS, JSONObject.class)).thenReturn(terms); when(jsonHelper.getKeyValue(terms, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_ON_DEMAND, JSONObject.class)).thenReturn(onDemand); when(jsonHelper.getKeyValue(onDemand, SKU, JSONObject.class)).thenReturn(onDemandSkuInformation); when(jsonHelper.getKeyValue(onDemandSkuInformation, SKU + Ec2OnDemandPricingUpdateServiceImpl.JSON_SKU_WRAPPER_SUFFIX, JSONObject.class)) .thenReturn(pricingWrapper); when(jsonHelper.getKeyValue(pricingWrapper, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_PRICE_DIMENSIONS, JSONObject.class)) .thenReturn(priceDimensions); when(jsonHelper.getKeyValue(priceDimensions, SKU + Ec2OnDemandPricingUpdateServiceImpl.JSON_SKU_WRAPPER_SUFFIX + Ec2OnDemandPricingUpdateServiceImpl.JSON_PRICE_DIMENSIONS_WRAPPER_SUFFIX, JSONObject.class)).thenReturn(innerPricingWrapper); when(jsonHelper.getKeyValue(innerPricingWrapper, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_PRICE_PER_UNIT, JSONObject.class)) .thenReturn(pricePerUnit); when(jsonHelper.getKeyValue(pricePerUnit, Ec2OnDemandPricingUpdateServiceImpl.JSON_PRICE_PER_UNIT_WRAPPER, String.class)).thenReturn(STRING_VALUE); verify(jsonHelper).getKeyValue(jsonObject, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_PRODUCTS, JSONObject.class); verify(jsonHelper).getKeyValue(products, EC2_PRODUCT_KEY, JSONObject.class); verify(jsonHelper).getKeyValue(product, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_SKU, String.class); verify(jsonHelper).getKeyValue(product, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_ATTRIBUTES, JSONObject.class); verify(jsonHelper).getKeyValue(jsonObject, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_TERMS, JSONObject.class); verify(jsonHelper).getKeyValue(terms, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_ON_DEMAND, JSONObject.class); verify(jsonHelper).getKeyValue(onDemand, SKU, JSONObject.class); verify(jsonHelper).getKeyValue(onDemandSkuInformation, SKU + Ec2OnDemandPricingUpdateServiceImpl.JSON_SKU_WRAPPER_SUFFIX, JSONObject.class); verify(jsonHelper).getKeyValue(pricingWrapper, Ec2OnDemandPricingUpdateServiceImpl.JSON_KEY_NAME_PRICE_DIMENSIONS, JSONObject.class); verify(jsonHelper).getKeyValue(priceDimensions, SKU + Ec2OnDemandPricingUpdateServiceImpl.JSON_SKU_WRAPPER_SUFFIX + Ec2OnDemandPricingUpdateServiceImpl.JSON_PRICE_DIMENSIONS_WRAPPER_SUFFIX,
/** * Sets a JSON response object as a workflow variable. * * @param responseObject the JSON object. * @param execution the delegate execution. * * @throws Exception if any problems were encountered. */ public void setJsonResponseAsWorkflowVariable(Object responseObject, DelegateExecution execution) throws Exception { String jsonResponse = jsonHelper.objectToJson(responseObject); setTaskWorkflowVariable(execution, VARIABLE_JSON_RESPONSE, jsonResponse); }