Package com.puppetlabs.geppetto.catalog

Examples of com.puppetlabs.geppetto.catalog.Catalog


      + "    )\n"
      + "    should contain_stage('main').with(\n" + "      'name' => 'main',\n" + "    )\n" + "  }\n" + "end\n";

  public void testCatalogRspec() throws Exception {
    File f = TestDataProvider.getTestFile(new Path("testData/sample1.json"));
    Catalog c = CatalogJsonSerializer.load(f);
    assertEquals("Should have the expected name", "testcentos.pilsen.cloudsmith.com", c.getName());

    CatalogRspecGenerator generator = new CatalogRspecGenerator();
    StringBuilder builder = new StringBuilder();
    generator.generate(c, builder);
    assertEquals(expectedRspec1, builder.toString());
View Full Code Here


public class TestJsonLoad extends TestCase {

  public void testLoadSample1() throws Exception {

    File f = TestDataProvider.getTestFile(new Path("testData/sample1.json"));
    Catalog c = CatalogJsonSerializer.load(f);

    assertEquals("Should have the expected name", "testcentos.pilsen.cloudsmith.com", c.getName());

    // Save the TargetEntry as a loadable resource
    ResourceSet resourceSet = new ResourceSetImpl();
    URI fileURI = URI.createFileURI(new File("testOutput/sample1.catalog").getAbsolutePath());
    Resource targetResource = resourceSet.createResource(fileURI);
View Full Code Here

  }

  public void testLoadSample2() throws Exception {

    File f = TestDataProvider.getTestFile(new Path("testData/sample2.json"));
    Catalog c = CatalogJsonSerializer.load(f);

    assertEquals("Should have the expected name", "testcentos.pilsen.cloudsmith.com", c.getName());
    // Save the TargetEntry as a loadable resource
    ResourceSet resourceSet = new ResourceSetImpl();
    URI fileURI = URI.createFileURI(new File("testOutput/sample2.catalog").getAbsolutePath());
    Resource targetResource = resourceSet.createResource(fileURI);
    targetResource.getContents().add(c);
View Full Code Here

  }

  public void testLoadSample3() throws Exception {

    File f = TestDataProvider.getTestFile(new Path("testData/sample3.json"));
    Catalog c = CatalogJsonSerializer.load(f);

    assertEquals("Should have the expected name", "backend.i-fcda579c", c.getName());
    // Save the TargetEntry as a loadable resource
    ResourceSet resourceSet = new ResourceSetImpl();
    URI fileURI = URI.createFileURI(new File("testOutput/sample3.catalog").getAbsolutePath());
    Resource targetResource = resourceSet.createResource(fileURI);
    targetResource.getContents().add(c);
View Full Code Here

    }

    @Override
    public Catalog deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException {
      final Catalog result = CatalogFactory.eINSTANCE.createCatalog();
      JsonObject jsonObj = json.getAsJsonObject();

      // Check the document type
      String documentType = getString(jsonObj, "document_type");
      if(!"Catalog".equals(documentType))
        throw new IllegalArgumentException("JSON document must be of 'Catalog' type");

      result.setMetadata(getMetadata(jsonObj, "metadata", context));

      // all the data is under a 'data' key
      JsonElement data = jsonObj.get("data");
      if(data == null)
        return result;
      if(!(data instanceof JsonObject))
        throw new IllegalStateException("Document 'data' is not a single object");

      // continue serialization under data
      jsonObj = data.getAsJsonObject();
      result.setName(getString(jsonObj, "name"));
      result.setVersion(getString(jsonObj, "version"));

      json = jsonObj.get("tags");
      if(json != null)
        deserializeInto(json, result.getTags(), String.class, context);

      json = jsonObj.get("classes");
      if(json != null)
        deserializeInto(json, result.getClasses(), String.class, context);

      json = jsonObj.get("resources");
      if(json != null)
        deserializeInto(json, result.getResources(), CatalogResourceImpl.class, context);

      json = jsonObj.get("edges");
      if(json != null)
        deserializeInto(json, result.getEdges(), CatalogEdgeImpl.class, context);

      return result;
    }
View Full Code Here

  public void produceDOTDeltaGraph(String catalogName, InputStream oldCatalogStream, IPath oldRoot,
      InputStream newCatalogStream, IPath newRoot, OutputStream dotStream, IProgressMonitor monitor)
      throws IOException {
    final SubMonitor ticker = SubMonitor.convert(monitor, 1000);
    CatalogDeltaGraphProducer graphProducer = injector.getInstance(CatalogDeltaGraphProducer.class);
    Catalog oldCatalog = CatalogJsonSerializer.load(oldCatalogStream);
    Catalog newCatalog = CatalogJsonSerializer.load(newCatalogStream);

    ICancel cancel = new ProgressMonitorCancelIndicator(ticker.newChild(IProgressMonitor.UNKNOWN), 1000);
    graphProducer.produceGraph(cancel, catalogName, oldCatalog, oldRoot, newCatalog, newRoot, dotStream);
  }
View Full Code Here

  public void produceDOTGraph(String catalogName, InputStream catalogStream, OutputStream dotStream,
      IProgressMonitor monitor, IPath root) throws IOException {
    final SubMonitor ticker = SubMonitor.convert(monitor, 1000);
    CatalogGraphProducer graphProducer = injector.getInstance(CatalogGraphProducer.class);
    ICancel cancel = new ProgressMonitorCancelIndicator(ticker.newChild(IProgressMonitor.UNKNOWN), 1000);
    Catalog catalog = CatalogJsonSerializer.load(catalogStream);

    graphProducer.produceGraph(cancel, catalog, catalogName, dotStream, root);
  }
View Full Code Here

  public void produceSVGDeltaGraph(String catalogName, InputStream oldCatalogStream, IPath oldRoot,
      InputStream newCatalogStream, IPath newRoot, OutputStream svgStream, IProgressMonitor monitor)
      throws IOException {
    final SubMonitor ticker = SubMonitor.convert(monitor, 2000);
    CatalogDeltaGraphProducer graphProducer = injector.getInstance(CatalogDeltaGraphProducer.class);
    Catalog oldCatalog = CatalogJsonSerializer.load(oldCatalogStream);
    Catalog newCatalog = CatalogJsonSerializer.load(newCatalogStream);

    ICancel cancel = new ProgressMonitorCancelIndicator(ticker.newChild(IProgressMonitor.UNKNOWN), 1000);

    ByteArrayOutputStream2 out = new ByteArrayOutputStream2();
View Full Code Here

  public void produceSVGGraph(String catalogName, InputStream catalogStream, OutputStream svgStream,
      IProgressMonitor monitor, IPath root) throws IOException {
    final SubMonitor ticker = SubMonitor.convert(monitor, 2000);
    CatalogGraphProducer graphProducer = injector.getInstance(CatalogGraphProducer.class);
    ICancel cancel = new ProgressMonitorCancelIndicator(ticker.newChild(IProgressMonitor.UNKNOWN), 1000);
    Catalog catalog = CatalogJsonSerializer.load(catalogStream);

    ByteArrayOutputStream2 out = new ByteArrayOutputStream2();
    graphProducer.produceGraph(cancel, catalog, catalogName, out, root);
    graphProducer.getSVGProducer().produceSVG(out.toInputStream(false), svgStream, false, //
    ticker.newChild(IProgressMonitor.UNKNOWN));
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.catalog.Catalog

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.