예제 #1
0
  @Test
  public void testParseGroups() {

    String value1 =
        group1
            + " "
            + ParserConstants.CONTAINS
            + " "
            + group1_member1
            + ParserConstants.SMALL_SEPARATOR
            + group1_member2
            + ParserConstants.SMALL_SEPARATOR
            + group1_member3;

    String value2 = group2 + " " + ParserConstants.CONTAINS + " " + group2_member1;

    Arguments argument =
        parse(ParserConstants.GROUPS_KEY, value1 + ParserConstants.BIG_SEPARATOR + value2);

    assertEquals(2, argument.getGroups().size());

    testGroup(
        group1,
        3,
        argument,
        new HashSet(Arrays.asList(group1_member1, group1_member2, group1_member3)),
        Collections.EMPTY_SET);
    testGroup(
        group2, 1, argument, new HashSet(Arrays.asList(group2_member1)), Collections.EMPTY_SET);
  }
 @Before
 public void setUp() {
   rulesSelector = new MockRulesSelector();
   DsmViewFactory dsmViewFactory = new DsmViewFactoryImpl();
   fileInputSelector = new MockFileInputSelector();
   windowManager = new MockWindowManager();
   aboutInfoDisplayer = new MockAboutInfoDisplayer();
   fileSelector = new MockFileSelector();
   dialogManager = new MockDialogManager();
   arguments = new Arguments();
   origInput = Arrays.asList("path1", "path2");
   arguments.setInput(origInput);
   arguments.setConfigFileName("original.properties");
   dependencyEngine = new MockDependencyEngine();
   dependencyEngineFactory = new DependencyEngineFactory(dependencyEngine);
   new MainViewFactoryImpl(
           dsmViewFactory,
           fileInputSelector,
           rulesSelector,
           fileSelector,
           windowManager,
           aboutInfoDisplayer,
           dialogManager,
           dependencyEngineFactory)
       .openMainView(arguments);
   view = new MainViewDriver(windowManager.getLastShownView());
 }
예제 #3
0
  // TODO simplify
  private void testGroup(
      String groupName,
      int numberOfGroupItems,
      Arguments argument,
      Set<String> included,
      Set<String> excluded) {
    Group group = argument.getGroups().get(groupName);

    assertTrue(argument.getGroups().containsKey(groupName));
    assertEquals(numberOfGroupItems, group.getGroupItems().size());

    for (String item : included) {
      assertTrue(group.getGroupItems().contains(item));
    }
    for (String item : excluded) {
      assertTrue(group.getExcludedItems().contains(item));
    }
  }
예제 #4
0
  @Test
  public void testParseGroupsWithExcludedItems() {
    String value1 =
        group2
            + " "
            + ParserConstants.CONTAINS
            + " "
            + group2_member1
            + " "
            + ParserConstants.DOES_NOT_CONTAIN
            + " "
            + group2_excluded1;

    String value2 =
        group2
            + " "
            + ParserConstants.CONTAINS
            + " "
            + group2_member1
            + " "
            + ParserConstants.DOES_NOT_CONTAIN
            + " "
            + group2_excluded1
            + ParserConstants.SMALL_SEPARATOR
            + group2_excluded2;

    Arguments argument = parse(ParserConstants.GROUPS_KEY, value1);
    assertEquals(1, argument.getGroups().size());
    testGroup(
        group2,
        1,
        argument,
        new HashSet(Arrays.asList(group2_member1)),
        new HashSet(Arrays.asList(group2_excluded1)));

    argument = parse(ParserConstants.GROUPS_KEY, value2);
    assertEquals(1, argument.getGroups().size());
    testGroup(
        group2,
        1,
        argument,
        new HashSet(Arrays.asList(group2_member1)),
        new HashSet(Arrays.asList(group2_excluded1, group2_excluded2)));
  }
예제 #5
0
 public synchronized DependencyEngine get(Arguments arguments) {
   DependencyEngine dependencyEngine = null;
   try {
     dependencyEngine = findEngine(arguments);
   } catch (DtException ex) {
     dependencyEngine = getDefaultEngine();
   }
   if (arguments.getDependencyEngineId() != null
       && arguments.getDependencyEngineId().length() > 0) {
     if (!(dependencyEngine != null
         && dependencyEngine.getDependencyEngineId() != null
         && dependencyEngine
             .getDependencyEngineId()
             .equalsIgnoreCase(arguments.getDependencyEngineId()))) {
       throw new DtException(
           "unable to find a dependency engine with id: " + arguments.getDependencyEngineId());
     }
   }
   ;
   return dependencyEngine;
 }
  @Test
  public void creatingANewConfiguration() {
    /*!
    A new configuration can be created by selecting **'New'** from
    the **'File'** menu or by pressing **Ctrl+N**.<br>
    This is essentially the same as resetting all configuration parameters
    back to their defaults.
    */
    assertEquals("DTangler DsmUI - original.properties", view.getTitle());
    view.inputButton.click();
    assertEquals(arguments.getInput(), fileInputSelector.getLastUsedDefaultInput().getPaths());

    view.menuBar.getMenu("File").getSubMenu("New").click();

    assertEquals("DTangler DsmUI - unsaved settings", view.getTitle());
    view.inputButton.click();
    assertTrue(fileInputSelector.getLastUsedDefaultInput().getPaths().isEmpty());
  }