@Test
  public void testDependentPicklistFields() throws ApiException {
    FieldDescription depender = this.getDescription("Contact", "Picklist_Depender__c");
    FieldDescription controller = this.getDescription("Contact", "Picklist_Controller__c");

    int[][] expected = {
      {1, 0, 0, 0, 0, 0, 0, 1, 0},
      {0, 1, 0, 0, 0, 0, 0, 1, 0},
      {0, 0, 1, 0, 0, 0, 0, 1, 0},
      {0, 0, 0, 1, 0, 0, 0, 1, 0},
      {1, 1, 1, 1, 1, 1, 1, 1, 1},
      {0, 0, 0, 0, 0, 1, 0, 1, 0},
      {0, 0, 0, 0, 0, 0, 1, 1, 0},
      {0, 0, 0, 0, 0, 0, 0, 1, 0},
      {0, 0, 0, 0, 0, 0, 0, 1, 1}
    };

    assertSame(Boolean.TRUE, depender.isDependentPicklist());
    assertNull(controller.isDependentPicklist());
    assertEquals(controller.getName(), depender.getControllerName());

    int size = 9;
    for (int dependendEntryIdx = 0; dependendEntryIdx < size; dependendEntryIdx++) {
      PicklistEntry dependentEntry = depender.getPicklistValues().get(dependendEntryIdx);

      for (int controllerEntryIdx = 0; controllerEntryIdx < size; controllerEntryIdx++) {
        boolean expectedValue = expected[dependendEntryIdx][controllerEntryIdx] == 1;

        assertEquals(
            "entry "
                + dependentEntry.getLabel()
                + " pos "
                + controllerEntryIdx
                + " "
                + dependentEntry.getValidFor(),
            expectedValue,
            dependentEntry.getValidFor().get(controllerEntryIdx));
      }
    }
  }
Пример #2
0
 public synchronized boolean equals(java.lang.Object obj) {
   if (!(obj instanceof PicklistEntry)) return false;
   PicklistEntry other = (PicklistEntry) obj;
   if (obj == null) return false;
   if (this == obj) return true;
   if (__equalsCalc != null) {
     return (__equalsCalc == obj);
   }
   __equalsCalc = obj;
   boolean _equals;
   _equals =
       true
           && this.active == other.isActive()
           && this.defaultValue == other.isDefaultValue()
           && ((this.label == null && other.getLabel() == null)
               || (this.label != null && this.label.equals(other.getLabel())))
           && ((this.validFor == null && other.getValidFor() == null)
               || (this.validFor != null && this.validFor.equals(other.getValidFor())))
           && ((this.value == null && other.getValue() == null)
               || (this.value != null && this.value.equals(other.getValue())));
   __equalsCalc = null;
   return _equals;
 }
  @SuppressWarnings({"unchecked"})
  @Test
  public void testPicklistField() throws ApiException {
    FieldDescription field = this.getDescription("Lead", "Industry");

    assertEquals(120, field.getByteLength());
    assertNull(field.getCalculatedFormula());
    assertNull(field.getControllerName());
    assertNull(field.getDefaultValueFormula());
    assertEquals(0, field.getDigits());
    assertNull(field.getInlineHelpText());
    assertEquals("Industry", field.getLabel());
    assertEquals(40, field.getLength());
    assertEquals("Industry", field.getName());
    assertEquals(32, field.getPicklistValues().size());

    List<PicklistEntry> expectedEntries =
        (List<PicklistEntry>)
            TestFixtureUtils.loadFixtures(
                "/sObjectFixtures/ConnectionTests/industryPicklistEntries.xml");
    for (int i = 0; i < expectedEntries.size(); i++) {
      PicklistEntry expected = expectedEntries.get(i);
      PicklistEntry actual = field.getPicklistValues().get(i);

      assertEquals(expected.getLabel(), actual.getLabel());
      assertEquals(expected.getValidFor(), actual.getValidFor());
      assertEquals(expected.getValue(), actual.getValue());
      assertEquals(expected.isActive(), actual.isActive());
      assertEquals(expected.isDefaultValue(), actual.isDefaultValue());
    }

    assertEquals(0, field.getPrecision());
    assertEquals(0, field.getReferenceTo().size());
    assertNull(field.getRelationshipName());
    assertNull(field.getRelationshipOrder());
    assertEquals(0, field.getScale());
    assertEquals(SoapTypeType.XSD___STRING, field.getSoapType());
    assertEquals(FieldTypeType.PICKLIST, field.getType());
    assertFalse(field.isAutoNumber());
    assertFalse(field.isCalculated());
    assertFalse(field.isCaseSensitive());
    assertTrue(field.isCreateable());
    assertFalse(field.isCustom());
    assertFalse(field.isDefaultedOnCreate());
    assertNull(field.isDependentPicklist());
    assertFalse(field.isDeprecatedAndHidden());
    assertNull(field.isExternalId());
    assertTrue(field.isFilterable());
    assertTrue(field.isGroupable());
    assertNull(field.isHtmlFormatted());
    assertFalse(field.isIdLookup());
    assertFalse(field.isNameField());
    assertEquals(Boolean.FALSE, field.isNamePointing());
    assertTrue(field.isNillable());
    assertFalse(field.isRestrictedPicklist());
    assertEquals(Boolean.TRUE, field.isSortable());
    assertFalse(field.isUnique());
    assertTrue(field.isUpdateable());
    assertNull(field.isWriteRequiresMasterRead());
    assertTrue(field.isPermissionable());
  }