Package com.atlassian.jira.rest.client.domain

Examples of com.atlassian.jira.rest.client.domain.CimFieldInfo


    final FieldSchema schema = fieldSchemaJsonParser.parse(json.getJSONObject("schema"));
    final Set<StandardOperation> operations = parseOperations(json.getJSONArray("operations"));
    final Iterable<Object> allowedValues = parseAllowedValues(json.optJSONArray("allowedValues"), schema);
    final URI autoCompleteUri = JsonParseUtil.parseOptionalURI(json, "autoCompleteUrl");

    return new CimFieldInfo(id, required, name, schema, operations, allowedValues, autoCompleteUri);
  }
View Full Code Here


    final CimIssueType issueType = EntityHelper.findEntityByName(project.getIssueTypes(), "Bug");
    final Map<String,CimFieldInfo> issueTypeFields = issueType.getFields();
    assertEquals(19, issueTypeFields.size());

    // test system field "components"
    final CimFieldInfo componentsFieldInfo = issueTypeFields.get("components");
    final CimFieldInfo expectedComponentsFieldInfo = new CimFieldInfo(
        "components", false, "Component/s", new FieldSchema("array", "component", "components", null, null),
        Sets.newHashSet(StandardOperation.ADD, StandardOperation.REMOVE, StandardOperation.SET),
        Collections.emptyList(), null
    );
    assertEquals(expectedComponentsFieldInfo, componentsFieldInfo);

    // check custom field with allowed values
    final CimFieldInfo cf1001 = issueTypeFields.get("customfield_10001");
    assertEquals(new FieldSchema("string", null, null, "com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons", 10001L), cf1001.getSchema());
    assertEquals(3, Iterables.size(cf1001.getAllowedValues()));
    assertThat(cf1001.getOperations(), containsInAnyOrder(StandardOperation.SET));

    // check allowed values types
    assertAllowedValuesOfType(issueTypeFields.get("issuetype").getAllowedValues(), BasicIssueType.class);
    assertAllowedValuesOfType(issueTypeFields.get("priority").getAllowedValues(), BasicPriority.class);
    assertAllowedValuesOfType(issueTypeFields.get("customfield_10001").getAllowedValues(), CustomFieldOption.class);
View Full Code Here

    final IssueInputBuilder builder = new IssueInputBuilder(project.getKey(), issueType.getId());

    // fill fields
    log.log("Filling fields:");
    for (Map.Entry<String, CimFieldInfo> entry : issueType.getFields().entrySet()) {
      final CimFieldInfo fieldInfo = entry.getValue();
      final String fieldCustomType = fieldInfo.getSchema().getCustom();
      final String fieldType = fieldInfo.getSchema().getType();
      final String fieldId = fieldInfo.getId();

      if ("project".equals(fieldId) || "issuetype".equals(fieldId)) {
        // this field was already set by IssueInputBuilder constructor - skip it
        continue;
      }

      log.log(MessageFormat.format("\t* [{0}] {1}\n\t\t| schema: {2}\n\t\t| required: {3}", fieldId, fieldInfo
          .getName(), fieldInfo.getSchema(), fieldInfo.isRequired()));

      // choose value for this field
      Object value = null;
      final Iterable<Object> allowedValues = fieldInfo.getAllowedValues();
      if (allowedValues != null) {
        log.log("\t\t| field only accepts those values:");
        for (Object val : allowedValues) {
          log.log("\t\t\t* " + val);
        }
        if (allowedValues.iterator().hasNext()) {
          final boolean expectedArray = "array".equals(fieldType);
          Object singleValue = allowedValues.iterator().next();

          if ("com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect".equals(fieldCustomType)) {
            // select option with children - if any
            final Iterable<Object> optionsWithChildren = Iterables.filter(allowedValues, new Predicate<Object>() {
              @Override
              public boolean apply(Object input) {
                return ((CustomFieldOption) input).getChildren().iterator().hasNext();
              }
            });

            if (optionsWithChildren.iterator().hasNext()) {
              // there is option with children - set it
              final CustomFieldOption option = (CustomFieldOption) optionsWithChildren.iterator().next();
              value = new CustomFieldOption(option.getId(), option.getSelf(), option.getValue(),
                Collections.<CustomFieldOption>emptyList(), option.getChildren().iterator().next());
            }
            else {
              // no sub-values available, set only top level value
              value = allowedValues.iterator().next();
            }
          }
          else {
            value = expectedArray ? Collections.singletonList(singleValue) : singleValue; 
          }
          log.log("\t\t| selecting value: " + value);
        } else {
          log.log("\t\t| there is no allowed value - leaving field blank");
        }
      } else {
        if ("com.atlassian.jirafisheyeplugin:jobcheckbox".equals(fieldCustomType)) {
          value = "false";
        }
        else if ("com.atlassian.jira.plugin.system.customfieldtypes:url".equals(fieldCustomType)) {
          value = "http://www.atlassian.com/";
        }
        else if ("string".equals(fieldType)) {
          value = "This is simple string value for field " + fieldId + " named " + fieldInfo.getName() + ".";
        } else if ("number".equals(fieldType)) {
          value = 124;
        } else if ("user".equals(fieldType)) {
          value = IntegrationTestUtil.USER_ADMIN;
        } else if ("array".equals(fieldType) && "user".equals(fieldInfo.getSchema().getItems())) {
          value = ImmutableList.of(IntegrationTestUtil.USER_ADMIN);
        } else if ("group".equals(fieldType)) {
          // TODO change to group object when implemented
          value = ComplexIssueInputFieldValue.with("name", IntegrationTestUtil.GROUP_JIRA_ADMINISTRATORS);
        } else if ("array".equals(fieldType) && "group".equals(fieldInfo.getSchema().getItems())) {
          // TODO change to group object when implemented
          value = ImmutableList.of(ComplexIssueInputFieldValue.with("name", IntegrationTestUtil.GROUP_JIRA_ADMINISTRATORS));
        } else if ("date".equals(fieldType)) {
          value = JsonParseUtil.formatDate(new DateTime());
        } else if ("datetime".equals(fieldType)) {
          value = JsonParseUtil.formatDateTime(new DateTime());
        } else if ("array".equals(fieldType) && "string".equals(fieldInfo.getSchema().getItems())) {
          value = ImmutableList.of("one", "two", "three");
        } else if ("timetracking".equals(fieldType)) {
          value = new TimeTracking(60, 40, null); // time spent is not allowed
        } else {
          if (fieldInfo.isRequired()) {
            fail("I don't know how to fill that required field, sorry.");
          } else {
            log.log("\t\t| field value is not required, leaving blank");
          }
        }
View Full Code Here

    final FieldSchema schema = fieldSchemaJsonParser.parse(json.getJSONObject("schema"));
    final Set<StandardOperation> operations = parseOperations(json.getJSONArray("operations"));
    final Iterable<Object> allowedValues = parseAllowedValues(json.optJSONArray("allowedValues"), schema);
    final URI autoCompleteUri = JsonParseUtil.parseOptionalURI(json, "autoCompleteUrl");

    return new CimFieldInfo(id, required, name, schema, operations, allowedValues, autoCompleteUri);
  }
View Full Code Here

    final FieldSchema schema = fieldSchemaJsonParser.parse(json.getJSONObject("schema"));
    final Set<StandardOperation> operations = parseOperations(json.getJSONArray("operations"));
    final Iterable<Object> allowedValues = parseAllowedValues(json.optJSONArray("allowedValues"), schema);
    final URI autoCompleteUri = JsonParseUtil.parseOptionalURI(json, "autoCompleteUrl");

    return new CimFieldInfo(id, required, name, schema, operations, allowedValues, autoCompleteUri);
  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.domain.CimFieldInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.