예제 #1
0
  private String getInterfaceForAlias(String aliasName) {
    ScenarioAliases scenarioAliases = getAliases();

    if (scenarioAliases != null) {
      AliasDefinition aliasDefinitions = scenarioAliases.getAlias(aliasName);

      if (aliasDefinitions != null) {
        return aliasDefinitions.getInterfaceName();
      }
    }
    return null;
  }
예제 #2
0
  /* (non-Javadoc)
   * @see com.caplin.cutlass.bundler.js.aliasing.SomeSortOfInterface#addClassAlias(org.bladerunnerjs.model.AliasDefinition, java.lang.String)
   */
  @Override
  public void addClassAlias(AliasDefinition alias, String scenario)
      throws ContentProcessingException {
    ScenarioAliases scenarioAliases = getScenarioAliases(scenario);

    String className = alias.getClassName();

    if (className != null && !validClasses.contains(className)) {
      throw new ContentProcessingException("There is no such class as '" + className + "'.");
    }

    verifyAliasDoesNotClash(alias, scenarioAliases.getAlias(alias.getName()));
    // TODO check for clashes
    scenarioAliases.addAlias(alias.getName(), alias);
  }
예제 #3
0
  public String getJson(ClassDictionary classDictionary, ScenarioAliases activeAliases) {
    StringBuilder jsonData = new StringBuilder();
    boolean firstAlias = true;

    jsonData.append("{");

    for (String aliasName : activeAliases.getAliasNames()) {
      AliasDefinition aliasDefinition = activeAliases.getAlias(aliasName);

      if (firstAlias) {
        firstAlias = false;
      } else {
        jsonData.append(",");
      }

      jsonData.append("'" + aliasName + "':{");

      if (aliasDefinition.getClassName() != null) {
        jsonData.append(
            "'class':"
                + aliasDefinition.getClassName()
                + ",'className':'"
                + aliasDefinition.getClassName()
                + "'");
      }

      if (aliasDefinition.getInterfaceName() != null) {
        if (aliasDefinition.getClassName() != null) {
          jsonData.append(",");
        }

        jsonData.append(
            "'interface':"
                + aliasDefinition.getInterfaceName()
                + ",'interfaceName':'"
                + aliasDefinition.getInterfaceName()
                + "'");
      }

      jsonData.append("}");
    }

    jsonData.append("}");

    return jsonData.toString();
  }
예제 #4
0
  @Before
  public void setUp() {
    BRJSAccessor.initialize(BRJSTestFactory.createBRJS(new File(testBase)));

    activeAliases = new ScenarioAliases();

    activeAliases.addAlias("bar", sdkFooBar);
  }
예제 #5
0
  @Test
  @Ignore
  public void verifyAliasWithNoClassReturnsNull() throws ContentProcessingException {
    activeAliases.addAlias("alias #1", new AliasDefinition(null, null, null));

    File testDir = new File(testBase, "single-alias-file/default-aspect");
    Set<String> validClasses =
        SourceFileLocator.createValidClasses(SourceFileLocator.getAllSourceFiles(testDir, null));
    AliasRegistry aliasRegistry = new AliasRegistry(testDir, null, validClasses);

    assertEquals(nullClassJson, aliasRegistry.getJson(classDictionary, activeAliases));
  }
예제 #6
0
  @Test
  @Ignore
  public void verifySingleAliasFile() throws ContentProcessingException {
    activeAliases.addAlias("alias #1", alias1);
    activeAliases.addAlias("alias #2", alias2);

    File testDir = new File(testBase, "single-alias-file/default-aspect");
    Set<String> validClasses =
        SourceFileLocator.createValidClasses(SourceFileLocator.getAllSourceFiles(testDir, null));
    AliasRegistry aliasRegistry = new AliasRegistry(testDir, null, validClasses);

    assertEquals(defaultScenarioJson, aliasRegistry.getJson(classDictionary, activeAliases));
  }
예제 #7
0
  @Test
  @Ignore
  public void verifyAliasFileCanSwitchScenario() throws ContentProcessingException {
    activeAliases.addAlias("novox.example.blade1.alias #1", group1blade1alias1test);
    activeAliases.addAlias("novox.example.blade1.alias #2", group1blade1alias2test);

    File testDir = new File(testBase, "alias-file-switching-scenario/default-aspect");
    Set<String> validClasses =
        SourceFileLocator.createValidClasses(SourceFileLocator.getAllSourceFiles(testDir, null));
    AliasRegistry aliasRegistry = new AliasRegistry(testDir, null, validClasses);

    assertEquals(testScenarioJson, aliasRegistry.getJson(classDictionary, activeAliases));
  }
예제 #8
0
  @Test
  @Ignore
  public void verifyAliasFileCanOverrideAnAliasDefinitionsFile() throws ContentProcessingException {
    activeAliases.addAlias("novox.example.blade1.alias #1", group1blade1alias1);
    activeAliases.addAlias("novox.example.blade1.alias #2", group1blade1alias2);

    File testDir =
        new File(testBase, "alias-file-overriding-an-alias-definitions-file/default-aspect");
    Set<String> validClasses =
        SourceFileLocator.createValidClasses(SourceFileLocator.getAllSourceFiles(testDir, null));
    AliasRegistry aliasRegistry = new AliasRegistry(testDir, null, validClasses);

    assertEquals(overriddenJson, aliasRegistry.getJson(classDictionary, activeAliases));
  }
예제 #9
0
  private void defaultMissingAliases() {
    ScenarioAliases scenarioAliases = getAliases();
    ScenarioAliases defaultAliases = aliasScenarios.getScenarioAliases(DEFAULT_SCENARIO);

    for (String aliasName : defaultAliases.getAliasNames()) {
      if (!scenarioAliases.hasAlias(aliasName)) {
        AliasDefinition aliasDefinitions = defaultAliases.getAlias(aliasName);

        scenarioAliases.addAlias(aliasName, new AliasDefinition(aliasDefinitions));
      }
    }
  }