Package com.puppetlabs.geppetto.pp.pptp

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


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


          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

  }

  public List<TypeFragment> loadTypeFragments(File rbFile) throws IOException, RubySyntaxException {
    List<TypeFragment> result = Lists.newArrayList();
    for(PPTypeInfo type : getTypeFragments(rbFile)) {
      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);
      }

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

    Resource r = resourceSet.getResource(uri, true);

    assertEquals("Should have loaded one thing", 1, r.getContents().size());
    EObject t = r.getContents().get(0);
    assertTrue("Should have loaded a typeFragment", t instanceof TypeFragment);
    TypeFragment type = (TypeFragment) t;
    assertEquals("Name should be the expected name", typeName, type.getName());
    return type;
  }
View Full Code Here

    assertEquals("Should have found a missing description of 'empty'", "", emptyEntry.getDocumentation());
  }

  @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.TypeFragment

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.