Package com.puppetlabs.geppetto.pp.pptp

Examples of com.puppetlabs.geppetto.pp.pptp.Property


      assertEquals("Should have found 'mocktype'", "mocktype", type.getName());
      assertEquals("Should have found documentation", "<p>This is a mock type</p>", type.getDocumentation());

      assertEquals("Should have one property", 1, type.getProperties().size());
      {
        Property prop = getProperty("prop1", type);
        assertNotNull("Should have a property 'prop1", prop);
        assertEquals("Should have defined documentation", "<p>This is property1</p>", prop.getDocumentation());
      }
      {
        assertEquals("Should have one parameter", 1, type.getParameters().size());
        Parameter param = getParameter("param1", type);
        assertNotNull("Should have a parameter 'param1", param);
        assertEquals("Should have defined documentation", "<p>This is parameter1</p>", param.getDocumentation());
      }

      // There should be two type fragments, with a contribution each
      List<TypeFragment> typeFragments = target.getTypeFragments();
      assertEquals("Should have found two fragments", 2, typeFragments.size());

      TypeFragment fragment1 = typeFragments.get(0);
      TypeFragment fragment2 = typeFragments.get(1);
      boolean fragment1HasExtra1 = getProperty("extra1", fragment1) != null;
      {
        Property prop = getProperty("extra1", fragment1HasExtra1
            ? fragment1
            : fragment2);
        assertNotNull("Should have a property 'extra1", prop);
        assertEquals(
          "Should have defined documentation", "<p>An extra property called extra1</p>",
          prop.getDocumentation());
      }
      {
        Property prop = getProperty("extra2", fragment1HasExtra1
            ? fragment2
            : fragment1);
        assertNotNull("Should have a property 'extra2", prop);
        assertEquals(
          "Should have defined documentation", "<p>An extra property called extra2</p>",
          prop.getDocumentation());
      }

      // should have found two functions "echotest" and "echotest2"
      // and the log functions (8)
      assertEquals("Should have found two functions", 10, target.getFunctions().size());
View Full Code Here


              parameter.setDocumentation(entry.getValue().documentation);
              parameter.setRequired(entry.getValue().isRequired());
              type.getParameters().add(parameter);
            }
            for(Map.Entry<String, PPTypeInfo.Entry> entry : info.getProperties().entrySet()) {
              Property property = PPTPFactory.eINSTANCE.createProperty();
              property.setName(entry.getKey());
              property.setDocumentation(entry.getValue().documentation);
              property.setRequired(entry.getValue().isRequired());
              type.getProperties().add(property);
            }
            getContents().add(type);
          }
        }
          break;

        case FUNCTION: {
          List<PPFunctionInfo> functions = helper.getFunctionInfo(uri.path(), new InputStreamReader(
            inputStream));

          for(PPFunctionInfo info : functions) {
            Function pptpFunc = PPTPFactory.eINSTANCE.createFunction();
            pptpFunc.setName(info.getFunctionName());
            pptpFunc.setRValue(info.isRValue());
            pptpFunc.setDocumentation(info.getDocumentation());
            getContents().add(pptpFunc);
          }
        }
          break;

        case META: {
          PPTypeInfo info = helper.getMetaTypeInfo(uri.path(), new InputStreamReader(inputStream));

          MetaType type = PPTPFactory.eINSTANCE.createMetaType();
          type.setName(info.getTypeName());
          type.setDocumentation(info.getDocumentation());
          for(Map.Entry<String, PPTypeInfo.Entry> entry : info.getParameters().entrySet()) {
            Parameter parameter = PPTPFactory.eINSTANCE.createParameter();
            parameter.setName(entry.getKey());
            parameter.setDocumentation(entry.getValue().documentation);
            parameter.setRequired(entry.getValue().isRequired());
            type.getParameters().add(parameter);
          }
          // TODO: Scan the puppet source for providers for the type
          // This is a CHEAT -
          // https://github.com/puppetlabs/geppetto/issues/37
          Parameter p = PPTPFactory.eINSTANCE.createParameter();
          p.setName("provider");
          p.setDocumentation("");
          p.setRequired(false);
          type.getParameters().add(p);

          getContents().add(type);
          break;
        }

        case TYPEFRAGMENT: {
          for(PPTypeInfo type : helper.getTypeFragments(uri.path(), new InputStreamReader(inputStream))) {
            TypeFragment fragment = PPTPFactory.eINSTANCE.createTypeFragment();
            fragment.setName(type.getTypeName());

            // add the properties (will typically load just one).
            for(Map.Entry<String, PPTypeInfo.Entry> entry : type.getProperties().entrySet()) {
              Property property = PPTPFactory.eINSTANCE.createProperty();
              property.setName(entry.getKey());
              property.setDocumentation(entry.getValue().documentation);
              property.setRequired(entry.getValue().isRequired());
              fragment.getProperties().add(property);
            }

            // add the parameters (will typically load just one).
            for(Map.Entry<String, PPTypeInfo.Entry> entry : type.getParameters().entrySet()) {
View Full Code Here

      TypeFragment fragment = PPTPFactory.eINSTANCE.createTypeFragment();
      fragment.setName(type.getTypeName());

      // add the properties (will typically load just one).
      for(Map.Entry<String, PPTypeInfo.Entry> entry : type.getProperties().entrySet()) {
        Property property = PPTPFactory.eINSTANCE.createProperty();
        property.setName(entry.getKey());
        property.setDocumentation(entry.getValue().documentation);
        property.setRequired(entry.getValue().isRequired());
        fragment.getProperties().add(property);
      }

      // add the parameters (will typically load just one).
      for(Map.Entry<String, PPTypeInfo.Entry> entry : type.getParameters().entrySet()) {
View Full Code Here

        parameter.setRequired(entry.getValue().isRequired());
        parameter.setNamevar(entry.getValue().isNamevar());
        type.getParameters().add(parameter);
      }
      for(Map.Entry<String, PPTypeInfo.Entry> entry : info.getProperties().entrySet()) {
        Property property = PPTPFactory.eINSTANCE.createProperty();
        property.setName(entry.getKey());
        property.setDocumentation(entry.getValue().documentation);
        property.setRequired(entry.getValue().isRequired());
        type.getProperties().add(property);
      }
      result.add(type);
    }
    return result;
View Full Code Here

      "Should have found a description of 'name'", "<p>Description of name</p>", nameEntry.getDocumentation());

    Parameter ensure = findParameter(type, "ensure");
    assertNotNull("Should have found a parameter called 'ensure'", ensure);

    Property weightEntry = findProperty(type, "weight");
    assertNotNull("Should have found a property called 'weight'", weightEntry);
    assertEquals(
      "Should have found a description of 'weight'", "<p>Description of weight</p>",
      weightEntry.getDocumentation());

    Property emptyEntry = findProperty(type, "empty");
    assertNotNull("Should have found a property called 'weight'", emptyEntry);
    assertEquals("Should have found a missing description of 'empty'", "", emptyEntry.getDocumentation());
  }
View Full Code Here

  @Test
  public void testTypeFragment() throws IOException {
    TypeFragment tf = doTypeFragmentResource(
      "testData/mock-puppet-distro/puppet-2.6.2_0/lib/puppet/type/mocktype/extra1.rb", "mocktype");
    assertEquals("Should have found one property", 1, tf.getProperties().size());
    Property extra1 = findProperty(tf, "extra1");
    assertNotNull("Should have found extra1", extra1);

    tf = doTypeFragmentResource(
      "testData/mock-puppet-distro/puppet-2.6.2_0/lib/puppet/type/mocktype/extra2.rb", "mocktype");
    assertEquals("Should have found one property", 1, tf.getProperties().size());
    Property extra2 = findProperty(tf, "extra2");
    assertNotNull("Should have found extra2", extra2);

  }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.pp.pptp.Property

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.