コード例 #1
0
  /** IDE-1391 */
  @Test
  public void canInitialize() {
    Assert.assertFalse(PropertiesUtil.canInitialize(null));

    String[] initializeTrue =
        new String[] {
          "simple_property",
          "simplesequence_property",
          "struct_property",
          "structsequence_property",
          "simple_configure_property",
          "simple_readonly_property",
          "simplesequence_readonly_property",
          "struct_readonly_property",
          "structsequence_readonly_property"
        };

    String[] initializeFalse =
        new String[] {
          "simple_configure",
          "simple_empty",
          "simplesequence_empty",
          "struct_empty",
          "structsequence_empty",
          "simple_execparam_property",
          "simple_execparam",
          "simple_commandline_property",
          "simple_readonly_commandline_property"
        };

    Assert.assertEquals(
        initializeTrue.length + initializeFalse.length, props.getProperties().size());
    for (String property : initializeTrue) {
      AbstractProperty prop = props.getProperty(property);
      Assert.assertNotNull("Property not found in PRF: " + property, prop);
      Assert.assertTrue(
          "Should be able to initialize " + property, PropertiesUtil.canInitialize(prop));
    }
    for (String property : initializeFalse) {
      AbstractProperty prop = props.getProperty(property);
      Assert.assertNotNull("Property not found in PRF: " + property, prop);
      Assert.assertFalse(
          "Should NOT be able to initialize " + property, PropertiesUtil.canInitialize(prop));
    }
  }
コード例 #2
0
  /** IDE-1654 */
  @Test
  public void isCommandLine() {
    String[] isCmdLnTrue =
        new String[] {
          "simple_execparam_property",
          "simple_execparam",
          "simple_commandline_property",
          "simple_readonly_commandline_property",
        };

    String[] isCmdLnFalse =
        new String[] {
          "simple_property",
          "simplesequence_property",
          "struct_property",
          "structsequence_property",
          "simple_empty",
          "simplesequence_empty",
          "struct_empty",
          "structsequence_empty",
          "simple_configure",
          "simple_configure_property",
          "simple_readonly_property",
          "simplesequence_readonly_property",
          "struct_readonly_property",
          "structsequence_readonly_property"
        };

    Assert.assertEquals(isCmdLnTrue.length + isCmdLnFalse.length, props.getProperties().size());
    for (String property : isCmdLnTrue) {
      AbstractProperty prop = props.getProperty(property);
      Assert.assertNotNull("Property not found in PRF: " + property, prop);
      Assert.assertTrue(
          property + " should be a valid command-line property",
          PropertiesUtil.isCommandLine(prop));
    }
    for (String property : isCmdLnFalse) {
      AbstractProperty prop = props.getProperty(property);
      Assert.assertNotNull("Property not found in PRF: " + property, prop);
      Assert.assertFalse(
          property + " should NOT be a valid command-line property",
          PropertiesUtil.isCommandLine(prop));
    }
  }
コード例 #3
0
 protected void updateSimpleRefs(Notification notification) {
   Simple simple = (Simple) notification.getNewValue();
   if (simple != null) { // Add Simple Refs associated with new value
     for (StructValue structValue : getStructValue()) {
       SimpleRef ref = PrfFactory.eINSTANCE.createSimpleRef();
       ref.setRefID(simple.getId());
       ref.setValue(PropertiesUtil.getDefaultValue(simple));
       SimpleRef oldRef = null;
       for (SimpleRef sr : structValue.getSimpleRef()) {
         if (sr.getRefID() != null && sr.getRefID().equals(simple.getId())) {
           oldRef = sr;
           break;
         }
       }
       if (oldRef != null) {
         structValue.getSimpleRef().remove(oldRef);
       }
       int index = this.getStruct().getSimple().indexOf(simple);
       structValue.getSimpleRef().add(index, ref);
     }
   } else { // Remove SimpleRefs associated with the oldValue
     simple = (Simple) notification.getOldValue();
     if (simple != null) {
       for (StructValue structValue : getStructValue()) {
         Collection<SimpleRef> removeRefs = null;
         for (SimpleRef ref : structValue.getSimpleRef()) {
           if (ref.getRefID() != null && simple.getId() != null) {
             if (ref.getRefID().equals(simple.getId())) {
               removeRefs = Collections.singletonList(ref);
               break;
             }
           } else if (ref.getRefID() == null && simple.getId() == null) {
             removeRefs = Collections.singletonList(ref);
             break;
           }
         }
         if (removeRefs != null) {
           structValue.getSimpleRef().removeAll(removeRefs);
         }
       }
     }
   }
 }