Package com.puppetlabs.geppetto.pp.pptp

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


        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());
View Full Code Here


          for(PPTypeInfo info : typeInfo) {
            Type type = PPTPFactory.eINSTANCE.createType();
            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);
            }
            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()) {
              Parameter parameter = PPTPFactory.eINSTANCE.createParameter();
              parameter.setName(entry.getKey());
              parameter.setDocumentation(entry.getValue().documentation);
              parameter.setRequired(entry.getValue().isRequired());
              fragment.getParameters().add(parameter);
            }
            getContents().add(fragment);
          }
          break;
View Full Code Here

    PPTypeInfo info = getMetaTypeInfo(rbFile);
    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);

    // TODO: there are more interesting things to pick up (like valid
    // values)
    target.setMetaType(type);
View Full Code Here

        fragment.getProperties().add(property);
      }

      // add the parameters (will typically load just one).
      for(Map.Entry<String, PPTypeInfo.Entry> entry : type.getParameters().entrySet()) {
        Parameter parameter = PPTPFactory.eINSTANCE.createParameter();
        parameter.setName(entry.getKey());
        parameter.setDocumentation(entry.getValue().documentation);
        parameter.setRequired(entry.getValue().isRequired());
        fragment.getParameters().add(parameter);
      }

      result.add(fragment);
    }
View Full Code Here

    for(PPTypeInfo info : typeInfos) {
      Type type = PPTPFactory.eINSTANCE.createType();
      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());
        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());
View Full Code Here

    else if(PPTPPackage.Literals.TARGET_ELEMENT.isSuperTypeOf(eObject.eClass())) {
      Map<String, String> data = Maps.newHashMapWithExpectedSize(1);
      if(((TargetElement) eObject).isDeprecated())
        data.put(PPDSLConstants.ELEMENT_DEPRECATED, "true");
      if(eObject.eClass() == PPTPPackage.Literals.PARAMETER) {
        Parameter p = (Parameter) eObject;
        if(p.isNamevar())
          data.put(PPDSLConstants.PARAMETER_NAMEVAR, "true");
        return data;
      }
      if(eObject.eClass() == PPTPPackage.Literals.TP_VARIABLE) {
        TPVariable tpvar = (TPVariable) eObject;
View Full Code Here

    Type type = doTypeResource("testData/pp-modules-ruby/module-x/lib/puppet/type/thing.rb", "thing");

    assertEquals("Should have found two parameter", 2, type.getParameters().size());
    assertEquals("Should have found two properties", 2, type.getProperties().size());

    Parameter nameEntry = findParameter(type, "name");
    assertNotNull("Should have found a parameter called 'name'", nameEntry);
    assertEquals(
      "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(
View Full Code Here

TOP

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

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.