示例#1
0
  /** This is called in the unhappy event of there being errors. */
  public static void showBuilderErrors(
      BuilderResult results, Panel buildResults, ClientFactory clientFactory) {
    buildResults.clear();

    BuildPackageErrorsSimpleTable errorsTable = new BuildPackageErrorsSimpleTable(clientFactory);
    errorsTable.setRowData(results.getLines());
    errorsTable.setRowCount(results.getLines().size());
    buildResults.add(errorsTable);
  }
  private BuilderResult buildPackage(
      PackageItem item, boolean force, PackageAssemblerConfiguration packageAssemblerConfiguration)
      throws DetailedSerializationException {
    if (!force && item.isBinaryUpToDate()) {
      // we can just return all OK if its up to date.
      return BuilderResult.emptyResult();
    }
    PackageAssembler packageAssembler = new PackageAssembler(item, packageAssemblerConfiguration);

    packageAssembler.compile();

    if (packageAssembler.hasErrors()) {
      BuilderResult result = new BuilderResult();
      BuilderResultHelper builderResultHelper = new BuilderResultHelper();
      result.addLines(builderResultHelper.generateBuilderResults(packageAssembler.getErrors()));
      return result;
    }

    updatePackageBinaries(item, packageAssembler);

    return BuilderResult.emptyResult();
  }
示例#3
0
  @Test
  public void testValidating() throws Exception {
    RulesRepository repo = getRulesRepository();
    PackageItem pkg = repo.loadDefaultPackage();
    AssetItem asset = pkg.addAsset("testValidatingEnum", "");
    asset.updateFormat(AssetFormats.ENUMERATION);
    asset.updateContent("'Person.age' : [1, 2, 3]");

    EnumerationContentHandler ch = new EnumerationContentHandler();
    BuilderResult result = ch.validateAsset(asset);
    assertNotNull(result);
    assertEquals(0, result.getLines().size());

    asset.updateContent("goober boy");
    result = ch.validateAsset(asset);
    assertFalse(result.getLines().size() == 0);
    assertEquals(asset.getName(), result.getLines().get(0).getAssetName());
    assertEquals(asset.getFormat(), result.getLines().get(0).getAssetFormat());
    assertNotNull(result.getLines().get(0).getMessage());
    assertEquals(asset.getUUID(), result.getLines().get(0).getUuid());
  }