Java Code Examples for com.fasterxml.jackson.databind.node.ObjectNode#set()

The following examples show how to use com.fasterxml.jackson.databind.node.ObjectNode#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VirtualPortWebResource.java    From onos with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getportsById(@PathParam("id") String id) {

    if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {
        return Response.status(NOT_FOUND)
                .entity(VPORT_NOT_FOUND).build();
    }
    VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class)
            .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND);
    ObjectNode result = new ObjectMapper().createObjectNode();
    result.set("port", new VirtualPortCodec().encode(virtualPort, this));
    return ok(result.toString()).build();
}
 
Example 2
Source File: WithProductTypeReferencesTest.java    From commercetools-sync-java with Apache License 2.0 6 votes vote down vote up
@Test
void resolveReferences_WithNullNodeIdFieldInProductTypeReferenceAttribute_ShouldNotResolveReferences() {
    // preparation
    final ObjectNode attributeValue = JsonNodeFactory.instance.objectNode();
    attributeValue.put(REFERENCE_TYPE_ID_FIELD, ProductType.referenceTypeId());
    attributeValue.set(REFERENCE_ID_FIELD, JsonNodeFactory.instance.nullNode());

    final AttributeDraft productTypeReferenceAttribute =
        AttributeDraft.of("attributeName", attributeValue);

    final ProductVariantDraft productVariantDraft = ProductVariantDraftBuilder
        .of()
        .attributes(productTypeReferenceAttribute)
        .build();

    // test
    final ProductVariantDraft resolvedAttributeDraft =
        referenceResolver.resolveReferences(productVariantDraft)
                         .toCompletableFuture()
                         .join();
    // assertions
    assertThat(resolvedAttributeDraft).isEqualTo(productVariantDraft);
}
 
Example 3
Source File: DmWebResourceTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateDm() throws CfmConfigException, SoamConfigException {
    MepEntry mep1 = DefaultMepEntry.builder(MEPID1, DeviceId.deviceId("netconf:1.2.3.4:830"),
            PortNumber.portNumber(1), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).buildEntry();

    expect(mepService.getMep(MDNAME1, MANAME1, MEPID1)).andReturn(mep1).anyTimes();
    replay(mepService);

    ObjectMapper mapper = new ObjectMapper();
    CfmCodecContext context = new CfmCodecContext();
    ObjectNode node = mapper.createObjectNode();
    node.set("dm", context.codec(DelayMeasurementCreate.class).encode(dm1, context));

    final WebTarget wt = target();
    final Response response = wt.path("md/" + MDNAME1.mdName() + "/ma/" +
            MANAME1.maName() + "/mep/" + MEPID1.value() + "/dm")
            .request().post(Entity.json(node.toString()));

    assertEquals(201, response.getStatus());
}
 
Example 4
Source File: Dashboard.java    From kafka-metrics with Apache License 2.0 6 votes vote down vote up
private ObjectNode newPanel(ArrayNode rowPanels, String title, int span, String type) {
    ObjectNode panel = rowPanels.addObject();
    panel.put("title", title);
    panel.put("span", span);
    panel.put("id", ++numPanels);
    panel.put("datasource", dataSource);
    panel.put("type", type);
    panel.put("renderer", "flot");
    //
    panel.put("timeFrom", (String) null);
    panel.put("timeShift", (String) null);

    //
    panel.put("editable", true);
    panel.put("error", false);
    panel.put("isNew", true);
    //
    panel.set("targets", mapper.createArrayNode());
    return panel;
}
 
Example 5
Source File: Commons.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
public static InputStream
getLinksAsJSON(final String entitySetName, final Map.Entry<String, Collection<String>> link)
    throws IOException {

  final ObjectNode links = new ObjectNode(JsonNodeFactory.instance);
  links.put(
      Constants.get(ConstantKey.JSON_ODATAMETADATA_NAME),
      Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + entitySetName + "/$links/" + link.getKey());

  final ArrayNode uris = new ArrayNode(JsonNodeFactory.instance);

  for (String uri : link.getValue()) {
    final String absoluteURI;
    if (URI.create(uri).isAbsolute()) {
      absoluteURI = uri;
    } else {
      absoluteURI = Constants.get(ConstantKey.DEFAULT_SERVICE_URL) + uri;
    }
    uris.add(new ObjectNode(JsonNodeFactory.instance).put("url", absoluteURI));
  }

  if (uris.size() == 1) {
    links.setAll((ObjectNode) uris.get(0));
  } else {
    links.set("value", uris);
  }

  return IOUtils.toInputStream(links.toString(), Constants.ENCODING);
}
 
Example 6
Source File: ApiTest.java    From helios with Apache License 2.0 5 votes vote down vote up
/**
 * Verify that the Helios master generates and returns a hash if the submitted job creation
 * request does not include one.
 */
@Test
public void testHashLessJobCreation() throws Exception {
  startDefaultMaster();

  final Job job = Job.newBuilder()
      .setName(testJobName)
      .setVersion(testJobVersion)
      .setImage(BUSYBOX)
      .setCommand(IDLE_COMMAND)
      .setCreatingUser(TEST_USER)
      .build();

  // Remove the hash from the id in the json serialized job
  final ObjectNode json = (ObjectNode) Json.reader().readTree(Json.asString(job));
  json.set("id", TextNode.valueOf(testJobName + ":" + testJobVersion));

  final HttpURLConnection req = post("/jobs?user=" + TEST_USER,
      Json.asBytes(json));

  assertEquals(req.getResponseCode(), 200);

  final CreateJobResponse res = Json.read(toByteArray(req.getInputStream()),
      CreateJobResponse.class);

  assertEquals(OK, res.getStatus());
  assertTrue(res.getErrors().isEmpty());
  assertEquals(job.getId().toString(), res.getId());
}
 
Example 7
Source File: ProcessInstanceMigrationDocumentConverter.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected ObjectNode convertMappingInfoToJson(ActivityMigrationMapping.OneToManyMapping mapping, ObjectMapper objectMapper) {
    ObjectNode mappingNode = objectMapper.createObjectNode();
    mappingNode.put(FROM_ACTIVITY_ID_JSON_PROPERTY, mapping.getFromActivityId());
    JsonNode toActivityIdsNode = objectMapper.valueToTree(mapping.getToActivityIds());
    mappingNode.set(TO_ACTIVITY_IDS_JSON_PROPERTY, toActivityIdsNode);
    mappingNode.setAll(convertAdditionalMappingInfoToJson(mapping, objectMapper));
    return mappingNode;
}
 
Example 8
Source File: AdminConfigFile.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static void upgradeLdapIfNeeded(ObjectNode adminRootObjectNode) {
    JsonNode ldapNode = adminRootObjectNode.get("ldap");
    if (ldapNode == null || !ldapNode.isObject()) {
        return;
    }
    ObjectNode ldapObjectNode = (ObjectNode) ldapNode;
    JsonNode passwordNode = ldapObjectNode.remove("password");
    if (passwordNode != null) {
        // upgrade from 0.11.1 to 0.12.0
        ldapObjectNode.set("encryptedPassword", passwordNode);
    }
}
 
Example 9
Source File: CallActivityJsonConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void addJsonParameters(String propertyName, String valueName, List<IOParameter> parameterList, ObjectNode propertiesNode) {
  ObjectNode parametersNode = objectMapper.createObjectNode();
  ArrayNode itemsNode = objectMapper.createArrayNode();
  for (IOParameter parameter : parameterList) {
    ObjectNode parameterItemNode = objectMapper.createObjectNode();
    if (StringUtils.isNotEmpty(parameter.getSource())) {
      parameterItemNode.put(PROPERTY_IOPARAMETER_SOURCE, parameter.getSource());
    } else {
      parameterItemNode.putNull(PROPERTY_IOPARAMETER_SOURCE);
    }
    if (StringUtils.isNotEmpty(parameter.getTarget())) {
      parameterItemNode.put(PROPERTY_IOPARAMETER_TARGET, parameter.getTarget());
    } else {
      parameterItemNode.putNull(PROPERTY_IOPARAMETER_TARGET);
    }
    if (StringUtils.isNotEmpty(parameter.getSourceExpression())) {
      parameterItemNode.put(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION, parameter.getSourceExpression());
    } else {
      parameterItemNode.putNull(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION);
    }

    itemsNode.add(parameterItemNode);
  }

  parametersNode.set(valueName, itemsNode);
  propertiesNode.set(propertyName, parametersNode);
}
 
Example 10
Source File: CustomSerializationTest.java    From Rosetta with Apache License 2.0 5 votes vote down vote up
@Test
public void testAnnotatedSetterDeserialization() throws JsonProcessingException {
  ObjectNode node = Rosetta.getMapper().createObjectNode();
  node.set("annotatedSetter", expected);

  CustomSerializationBean bean = Rosetta.getMapper().treeToValue(node, CustomSerializationBean.class);
  assertThat(bean.getAnnotatedSetter()).containsExactlyElementsOf(stringList);
}
 
Example 11
Source File: BpmnJsonConverterUtil.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public static void convertMessagesToJson(BpmnModel bpmnModel, ObjectNode propertiesNode) {
    if (bpmnModel.getMessages() != null) {
        ArrayNode messageDefinitions = objectMapper.createArrayNode();
        for (Message message : bpmnModel.getMessages()) {
            ObjectNode messageNode = messageDefinitions.addObject();
            messageNode.put(PROPERTY_MESSAGE_DEFINITION_ID, message.getId());
            messageNode.put(PROPERTY_MESSAGE_DEFINITION_NAME, message.getName());
        }
        propertiesNode.set(PROPERTY_MESSAGE_DEFINITIONS, messageDefinitions);
    }
}
 
Example 12
Source File: PulsepointAdapterTest.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
@Test
public void makeHttpRequestsShouldFailIfAdUnitBidParamAdSizeWidthIsInvalid() {
    // given
    final ObjectNode params = mapper.createObjectNode();
    params.set("cp", new IntNode(1));
    params.set("ct", new IntNode(1));
    params.set("cf", new TextNode("invalidX500"));
    adapterRequest = givenBidder(builder -> builder.params(params));

    // when and then
    assertThatThrownBy(() -> adapter.makeHttpRequests(adapterRequest, preBidRequestContext))
            .isExactlyInstanceOf(PreBidException.class)
            .hasMessage("Invalid Width param invalid");
}
 
Example 13
Source File: LdTemplateController.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
    * Helper method to create a MCQ tool content. Title, instructions and questions are required (see tool for full
    * details of questions). Other fields are optional.
    */
   protected Long createMCQToolContent(UserDTO user, String title, String instructions,
    boolean useSelectLeaderToolOuput, boolean enableConfidenceLevel, boolean prefixAnswersWithLetters,
    ArrayNode questions) throws IOException {

ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, null, null, null);
toolContentJSON.put(RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, useSelectLeaderToolOuput);
toolContentJSON.set(RestTags.QUESTIONS, questions);
toolContentJSON.put(RestTags.ENABLE_CONFIDENCE_LEVELS, enableConfidenceLevel);
toolContentJSON.put("prefixAnswersWithLetters", prefixAnswersWithLetters);
return createToolContent(user, LdTemplateController.MCQ_TOOL_SIGNATURE, toolContentJSON);
   }
 
Example 14
Source File: ModelResource.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * PUT /rest/models/{modelId} -> update process model properties
 */
@PutMapping(value = "/rest/models/{modelId}")
public ModelRepresentation updateModel(@PathVariable String modelId, @RequestBody ModelRepresentation updatedModel) {
    // Get model, write-permission required if not a favorite-update
    Model model = modelService.getModel(modelId);

    ModelKeyRepresentation modelKeyInfo = modelService.validateModelKey(model, model.getModelType(), updatedModel.getKey());
    if (modelKeyInfo.isKeyAlreadyExists()) {
        throw new BadRequestException("Model with provided key already exists " + updatedModel.getKey());
    }

    try {
        updatedModel.updateModel(model);

        if (model.getModelType() != null) {
            ObjectNode modelNode = (ObjectNode) objectMapper.readTree(model.getModelEditorJson());
            modelNode.put("name", model.getName());
            modelNode.put("key", model.getKey());

            if (Model.MODEL_TYPE_BPMN == model.getModelType()) {
                ObjectNode propertiesNode = (ObjectNode) modelNode.get("properties");
                propertiesNode.put("process_id", model.getKey());
                propertiesNode.put("name", model.getName());
                if (StringUtils.isNotEmpty(model.getDescription())) {
                    propertiesNode.put("documentation", model.getDescription());
                }
                modelNode.set("properties", propertiesNode);
            }
            model.setModelEditorJson(modelNode.toString());
        }

        modelRepository.save(model);

        ModelRepresentation result = new ModelRepresentation(model);
        return result;

    } catch (Exception e) {
        throw new BadRequestException("Model cannot be updated: " + modelId);
    }
}
 
Example 15
Source File: UserReturnIndexer.java    From samantha with MIT License 4 votes vote down vote up
public ObjectNode getIndexedDataDAOConfig(RequestContext requestContext) {
    Map<String, Boolean> usedGroups = new HashMap<>();
    IndexerUtilities.loadUsedGroups(usedGroupsFilePath, separator, groupKeys, usedGroups);
    EntityDAO data = indexer.getEntityDAO(requestContext);
    GroupedEntityList userDao = new GroupedEntityList(groupKeys, null, data);
    try {
        BufferedWriter writer = new BufferedWriter(new FileWriter(filePath));
        IndexerUtilities.writeCSVHeader(dataFields, writer, separator);
        List<ObjectNode> acts;
        while ((acts = userDao.getNextGroup()).size() > 0) {
            if (usedGroups.size() > 0) {
                String grpStr = FeatureExtractorUtilities.composeConcatenatedKey(acts.get(0), groupKeys);
                if (!usedGroups.containsKey(grpStr)) {
                    continue;
                }
            }
            EntityDAO listDao = new EntityListDAO(acts);
            GroupedEntityList grouped = new GroupedEntityList(
                    Lists.newArrayList(sessionIdKey), null, listDao);
            List<ObjectNode> group = grouped.getNextGroup();
            List<ObjectNode> nextGrp;
            while ((nextGrp = grouped.getNextGroup()).size() > 0) {
                ObjectNode lastEntity = group.get(group.size() - 1);
                int lastTime = lastEntity.get(timestampField).asInt();
                int newTime = nextGrp.get(nextGrp.size() - 1).get(timestampField).asInt();
                double reward = getReward(lastTime, maxTime, newTime);
                if (reward >= 0.0) {
                    for (ObjectNode entity : group) {
                        entity.put(rewardKey, 0.0);
                        IndexerUtilities.writeCSVFields(entity, dataFields, writer, separator);
                    }
                    lastEntity.put(rewardKey, reward);
                    IndexerUtilities.writeCSVFields(lastEntity, dataFields, writer, separator);
                }
                group.clear();
                group = nextGrp;
            }
            acts.clear();
            listDao.close();
        }
        writer.close();
    } catch (IOException e) {
        throw new BadRequestException(e);
    }
    data.close();
    ObjectNode ret = Json.newObject();
    ret.put(daoNameKey, daoName);
    String path = JsonHelpers.getOptionalString(requestContext.getRequestBody(), filePathKey, filePath);
    ret.set(filesKey, Json.toJson(Lists.newArrayList(path)));
    ret.put(separatorKey, separator);
    return ret;
}
 
Example 16
Source File: LmEntryCodec.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public ObjectNode encode(LossMeasurementEntry lm, CodecContext context) {
    checkNotNull(lm, "LM cannot be null");
    ObjectNode result = context.mapper().createObjectNode()
            .put("lmId", lm.lmId().toString());

    if (lm.measuredForwardFlr() != null) {
        result.put("measuredForwardFlr", lm.measuredForwardFlr().percentValue());
    }
    if (lm.measuredBackwardFlr() != null) {
        result.put("measuredBackwardFlr", lm.measuredBackwardFlr().percentValue());
    }
    if (lm.measuredAvailabilityForwardStatus() != null) {
        result.put("measuredAvailabilityForwardStatus",
                lm.measuredAvailabilityForwardStatus().name());
    }
    if (lm.measuredAvailabilityBackwardStatus() != null) {
        result.put("measuredAvailabilityBackwardStatus",
                lm.measuredAvailabilityBackwardStatus().name());
    }
    if (lm.measuredForwardLastTransitionTime() != null) {
        result.put("measuredForwardLastTransitionTime",
                lm.measuredForwardLastTransitionTime().toString());
    }
    if (lm.measuredBackwardLastTransitionTime() != null) {
        result.put("measuredBackwardLastTransitionTime",
                lm.measuredBackwardLastTransitionTime().toString());
    }

    ObjectNode lmAttrs = new LmCreateCodec().encode(lm, context);
    Iterator<Entry<String, JsonNode>> elements = lmAttrs.fields();
    while (elements.hasNext()) {
        Entry<String, JsonNode> element = elements.next();
        result.set(element.getKey(), element.getValue());
    }

    if (lm.measurementCurrent() != null) {
        result.set("measurementCurrent", new LossMeasurementStatCurrentCodec()
                .encode(lm.measurementCurrent(), context));
    }

    if (lm.measurementHistories() != null) {
        result.set("measurementHistories", new LossMeasurementStatHistoryCodec()
                .encode(lm.measurementHistories(), context));
    }

    if (lm.availabilityCurrent() != null) {
        result.set("availabilityCurrent", new LossAvailabilityStatCurrentCodec()
                .encode(lm.availabilityCurrent(), context));
    }

    if (lm.availabilityHistories() != null) {
        result.set("availabilityHistories", new LossAvailabilityStatHistoryCodec()
                .encode(lm.availabilityHistories(), context));
    }

    return result;
}
 
Example 17
Source File: JSONEncoder.java    From arctic-sea with Apache License 2.0 4 votes vote down vote up
protected <T> void encodeList(ObjectNode json, String name, Collection<T> collection,
                              Function<T, JsonNode> encoder) {
    if (!collection.isEmpty()) {
        json.set(name, collection.stream().map(encoder).collect(toJsonArray()));
    }
}
 
Example 18
Source File: EmailProgressController.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
    * Gets learners or monitors of the lesson and organisation containing it.
    *
    * @throws SchedulerException
    */
   @RequestMapping("/getEmailProgressDates")
   @ResponseBody
   public String getEmailProgressDates(HttpServletRequest request, HttpServletResponse response)
    throws IOException, SchedulerException {
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
if (!securityService.isLessonMonitor(lessonId, getCurrentUser().getUserID(), "get class members", false)) {
    response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");
    return null;
}

HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);

ObjectNode responseJSON = JsonNodeFactory.instance.objectNode();
ArrayNode datesJSON = JsonNodeFactory.instance.arrayNode();

// find all the current dates set up to send the emails
String triggerPrefix = getTriggerPrefix(lessonId);
SortedSet<Date> currentDatesSet = new TreeSet<>();
Set<TriggerKey> triggerKeys = scheduler
	.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
    String triggerName = triggerKey.getName();
    if (triggerName.startsWith(triggerPrefix)) {
	Trigger trigger = scheduler.getTrigger(triggerKey);
	JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
	JobDataMap jobDataMap = jobDetail.getJobDataMap();

	// get only the trigger for the current lesson

	Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID);
	if (lessonId.equals(jobLessonId)) {

	    Date triggerDate = trigger.getNextFireTime();
	    currentDatesSet.add(triggerDate);
	}
    }
}

for (Date date : currentDatesSet) {
    datesJSON.add(createDateJSON(request.getLocale(), user, date, null));
}
responseJSON.set("dates", datesJSON);

response.setContentType("application/json;charset=utf-8");
return responseJSON.toString();
   }
 
Example 19
Source File: CaseInstanceQueryResourceTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
/**
 * Test querying case instance based on variables. POST query/case-instances
 */
@CmmnDeployment(resources = { "org/flowable/cmmn/rest/service/api/repository/oneHumanTaskCase.cmmn" })
public void testQueryCaseInstancesWithVariables() throws Exception {
    HashMap<String, Object> caseVariables = new HashMap<>();
    caseVariables.put("stringVar", "Azerty");
    caseVariables.put("intVar", 67890);
    caseVariables.put("booleanVar", false);

    CaseInstance caseInstance = runtimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").variables(caseVariables).start();

    String url = CmmnRestUrls.createRelativeResourceUrl(CmmnRestUrls.URL_CASE_INSTANCE_QUERY);

    // Process variables
    ObjectNode requestNode = objectMapper.createObjectNode();
    ArrayNode variableArray = objectMapper.createArrayNode();
    ObjectNode variableNode = objectMapper.createObjectNode();
    variableArray.add(variableNode);
    requestNode.set("variables", variableArray);

    // String equals
    variableNode.put("name", "stringVar");
    variableNode.put("value", "Azerty");
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // Integer equals
    variableNode.removeAll();
    variableNode.put("name", "intVar");
    variableNode.put("value", 67890);
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // Boolean equals
    variableNode.removeAll();
    variableNode.put("name", "booleanVar");
    variableNode.put("value", false);
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // String not equals
    variableNode.removeAll();
    variableNode.put("name", "stringVar");
    variableNode.put("value", "ghijkl");
    variableNode.put("operation", "notEquals");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // Integer not equals
    variableNode.removeAll();
    variableNode.put("name", "intVar");
    variableNode.put("value", 45678);
    variableNode.put("operation", "notEquals");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // Boolean not equals
    variableNode.removeAll();
    variableNode.put("name", "booleanVar");
    variableNode.put("value", true);
    variableNode.put("operation", "notEquals");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // String equals ignore case
    variableNode.removeAll();
    variableNode.put("name", "stringVar");
    variableNode.put("value", "azeRTY");
    variableNode.put("operation", "equalsIgnoreCase");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // String not equals ignore case
    variableNode.removeAll();
    variableNode.put("name", "stringVar");
    variableNode.put("value", "HIJKLm");
    variableNode.put("operation", "notEqualsIgnoreCase");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // String like
    variableNode.put("name", "stringVar");
    variableNode.put("value", "Azer%");
    variableNode.put("operation", "like");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // String liek ignore case
    variableNode.put("name", "stringVar");
    variableNode.put("value", "AzEr%");
    variableNode.put("operation", "likeIgnoreCase");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // String equals without value
    variableNode.removeAll();
    variableNode.put("value", "Azerty");
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode, caseInstance.getId());

    // String equals with non existing value
    variableNode.removeAll();
    variableNode.put("value", "Azerty2");
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode);
}
 
Example 20
Source File: AnnotatedCodec.java    From onos with Apache License 2.0 3 votes vote down vote up
/**
 * Adds JSON encoding of the given item annotations to the specified node.
 *
 * @param node    node to add annotations to
 * @param entity  annotated entity
 * @param context encode context
 * @return the given node
 */
protected ObjectNode annotate(ObjectNode node, T entity, CodecContext context) {
    if (!entity.annotations().keys().isEmpty()) {
        JsonCodec<Annotations> codec = context.codec(Annotations.class);
        node.set("annotations", codec.encode(entity.annotations(), context));
    }
    return node;
}