@Test
  public void shouldTestCRUDShortTermRecommendations()
      throws URISyntaxException, MalformedURLException {
    try {
      recommendationsStorage.deleteShortTermResourceRecommendations(new URI(USER_URI));
    } catch (RecommendationsStorageException e) {
      fail("failed deleting short term recs");
    }

    List<WebResourceEnhanced> expectedRecs = PersistenceDomainFixtures.getResources();
    try {
      recommendationsStorage.storeShortTermResourceRecommendations(new URI(USER_URI), expectedRecs);
    } catch (RecommendationsStorageException e) {
      fail("failed storing short term recs");
    }

    List<WebResourceEnhanced> actualRecs = new ArrayList<WebResourceEnhanced>();
    try {
      actualRecs.addAll(
          recommendationsStorage.getShortTermResourceRecommendations(new URI(USER_URI)));
    } catch (RecommendationsStorageException e) {
      fail("failed getting short term recs");
    }

    assertNotNull(actualRecs);
    assertEqualsNoOrder(actualRecs.toArray(), expectedRecs.toArray());

    try {
      recommendationsStorage.deleteShortTermResourceRecommendations(new URI(USER_URI));
    } catch (RecommendationsStorageException e) {
      fail("failed deleting short term recs");
    }
  }
  @Test
  public void verifyTestDependsOnGroupsInheritance()
      throws SecurityException, NoSuchMethodException {
    {
      Method method = MTest3.class.getMethod("dependsOnGroups1", new Class[0]);
      ITestAnnotation test1 =
          (ITestAnnotation) m_finder.findAnnotation(method, ITestAnnotation.class);
      Assert.assertEqualsNoOrder(new String[] {"dog2", "dog1", "dog3"}, test1.getDependsOnGroups());
    }

    {
      Method method = MTest3.class.getMethod("dependsOnGroups2", new Class[0]);
      ITestAnnotation test1 =
          (ITestAnnotation) m_finder.findAnnotation(method, ITestAnnotation.class);
      Assert.assertEqualsNoOrder(new String[] {"dog1", "dog3"}, test1.getDependsOnGroups());
    }
  }
 public void findMatching() throws Exception {
   List<Integer> list =
       DatabaseUtil.getNumBArray(
           "select numb from array3 where (numb = numb)", nuodbConnection, pstmt);
   Assert.assertTrue(list.size() >= 1, "The list is empty");
   Integer[] actarr = list.toArray(new Integer[list.size()]);
   Integer[] exparr = {1, 3, 5, 7, 8};
   Assert.assertEqualsNoOrder(actarr, exparr);
 }
  @Test
  public void verifyTestGroupsInheritance() throws SecurityException, NoSuchMethodException {
    {
      Method method = MTest3.class.getMethod("groups1", new Class[0]);
      ITestAnnotation test1 =
          (ITestAnnotation) m_finder.findAnnotation(method, ITestAnnotation.class);
      Assert.assertEqualsNoOrder(
          new String[] {"method-test3", "child-class-test3", "base-class"}, test1.getGroups());
    }

    {
      Method method = MTest3.class.getMethod("groups2", new Class[0]);
      ITestAnnotation test1 =
          (ITestAnnotation) m_finder.findAnnotation(method, ITestAnnotation.class);
      Assert.assertEqualsNoOrder(
          new String[] {"child-class-test3", "base-class"}, test1.getGroups());
    }
  }
 public void concatNumbers() throws Exception {
   List<Integer> list =
       DatabaseUtil.getUnion(
           "select numa from array2 union select numb from array3", nuodbConnection, pstmt);
   Assert.assertTrue(list.size() >= 1, "The list is empty");
   Integer[] actarr = list.toArray(new Integer[list.size()]);
   Integer exparr[] = {0, 2, 4, 5, 6, 8, 9, 1, 3, 5, 7, 8};
   Assert.assertEqualsNoOrder(actarr, exparr);
 }
 @Test
 public void verifyConfigurationGroupsInheritance()
     throws SecurityException, NoSuchMethodException {
   Method method = MTest3.class.getMethod("beforeSuite", new Class[0]);
   IConfigurationAnnotation test1 =
       (IConfigurationAnnotation) m_finder.findAnnotation(method, IConfigurationAnnotation.class);
   Assert.assertEqualsNoOrder(
       new String[] {"method-test3", "child-class-test3", "base-class"}, test1.getGroups());
 }
  @Test
  public void twoListAreEqualInOrder() {
    List<String> l1 = new ArrayList<String>();
    List<String> l2 = new ArrayList<String>();
    l1.add("a1");
    l1.add("a2");
    l2.add("a2");
    l2.add("a1");

    Assert.assertEqualsNoOrder(l1.toArray(), l2.toArray());
  }
 @Test
 public void testProjectRecommendationsCRUD()
     throws URISyntaxException, MalformedURLException, RecommendationsStorageException {
   List<ProjectProfile> expected = PersistenceDomainFixtures.getProjects();
   recommendationsStorage.deleteProjectProfileRecommendations(new URI(USER_URI));
   recommendationsStorage.storeProjectProfileRecommendations(new URI(USER_URI), expected);
   List<ProjectProfile> actual =
       recommendationsStorage.getProjectRecommendations(new URI(USER_URI));
   Assert.assertNotNull(actual);
   Assert.assertEqualsNoOrder(actual.toArray(), expected.toArray());
   recommendationsStorage.deleteProjectProfileRecommendations(new URI(USER_URI));
 }
 @Test
 public void shouldSerializeAndDeserializeEmptyList()
     throws URISyntaxException, RecommendationsStorageException {
   recommendationsStorage.deleteResourceRecommendations(new URI(USER_URI));
   List<WebResourceEnhanced> emptyList = new ArrayList<WebResourceEnhanced>();
   recommendationsStorage.storeResourceRecommendations(new URI(USER_URI), emptyList);
   List<WebResourceEnhanced> actual =
       recommendationsStorage.getResourceRecommendations(new URI(USER_URI));
   Assert.assertNotNull(actual);
   Assert.assertEqualsNoOrder(actual.toArray(), emptyList.toArray());
   recommendationsStorage.deleteResourceRecommendations(new URI(USER_URI));
 }
Beispiel #10
0
 /**
  * Helper method to compare article properties
  *
  * @param actual - actual article
  * @param expected - article with expected properties
  */
 protected void compareArticles(ArticleInfo actual, Article expected) {
   assertNotNull(actual, "returned null article");
   assertEquals(actual.getDoi(), expected.getDoi(), "Article had incorrect doi");
   assertEquals(actual.geteIssn(), expected.geteIssn(), "returned incorrect eIssn");
   assertEquals(actual.getTitle(), expected.getTitle(), "Article had incorrect Title");
   assertEquals(
       actual.getDescription(), expected.getDescription(), "Article had incorrect description");
   assertEqualsNoOrder(
       actual.getCategories().toArray(),
       expected.getCategories().toArray(),
       "Incorrect categories");
 }
 @Test
 public void testExpertsRecommendationsCRUD()
     throws URISyntaxException, RecommendationsStorageException {
   recommendationsStorage.deleteExpertsRecommandationsForProject(new URI(PROJECT_URI));
   List<UserProfile> expected = PersistenceDomainFixtures.getUserProfiles();
   recommendationsStorage.storeExpertsRecommendations(new URI(PROJECT_URI), expected);
   List<UserProfile> actual =
       recommendationsStorage.getExpertsRecommendations(new URI(PROJECT_URI));
   Assert.assertNotNull(actual);
   Assert.assertEqualsNoOrder(actual.toArray(), expected.toArray());
   recommendationsStorage.deleteExpertsRecommandationsForProject(new URI(PROJECT_URI));
 }
Beispiel #12
0
 private static <T> void assertFreeNodesEquals(DynamicGraph<T> graph, T[] expected) {
   Assert.assertEqualsNoOrder(graph.getFreeNodes().toArray(), expected);
 }
Beispiel #13
0
  protected void checkAnnotationProperties(AnnotationView result, Annotation expected) {
    if (expected.getType() == AnnotationType.MINOR_CORRECTION) {
      assertEquals(
          result.getTitle(),
          "Minor Correction: " + expected.getTitle(),
          "Annotation view had incorrect title");
    } else if (expected.getType() == AnnotationType.FORMAL_CORRECTION) {
      assertEquals(
          result.getTitle(),
          "Formal Correction: " + expected.getTitle(),
          "Annotation view had incorrect title");
    } else if (expected.getType() == AnnotationType.RETRACTION) {
      assertEquals(
          result.getTitle(),
          "Retraction: " + expected.getTitle(),
          "Annotation view had incorrect title");
    }
    assertEquals(
        result.getBody(),
        "<p>" + expected.getBody() + "</p>",
        "Annotation view had incorrect body");
    assertEquals(
        result.getCompetingInterestStatement(),
        expected.getCompetingInterestBody() == null ? "" : expected.getCompetingInterestBody(),
        "Annotation view had incorrect ci statement");
    assertEquals(
        result.getAnnotationUri(),
        expected.getAnnotationUri(),
        "Annotation view had incorrect annotation uri");
    assertEquals(
        result.getCreatorID(),
        expected.getCreator().getID(),
        "Annotation view had incorrect creator id");
    assertEquals(
        result.getCreatorDisplayName(),
        expected.getCreator().getDisplayName(),
        "Annotation view had incorrect creator name");

    if (Arrays.asList(
            AnnotationType.FORMAL_CORRECTION,
            AnnotationType.MINOR_CORRECTION,
            AnnotationType.RETRACTION)
        .contains(expected.getType())) {
      assertTrue(result.isCorrection(), "Result should have been created as a correction");
    } else {
      assertFalse(result.isCorrection(), "Result should not have been created as a correction");
    }

    if (expected.getAnnotationCitation() == null) {
      assertNull(result.getCitation(), "returned non-null citation when null was expected");
    } else {
      assertNotNull(result.getCitation(), "returned null citation when non-null was expected");
      assertEquals(
          result.getCitation().getTitle(),
          expected.getAnnotationCitation().getTitle(),
          "Returned citation with incorrect title");
      assertEquals(
          result.getCitation().geteLocationId(),
          expected.getAnnotationCitation().getELocationId(),
          "Returned citation with incorrect eLocationId");
      assertEquals(
          result.getCitation().getJournal(),
          expected.getAnnotationCitation().getJournal(),
          "Returned citation with incorrect journal");
      assertEquals(
          result.getCitation().getYear(),
          expected.getAnnotationCitation().getYear(),
          "Returned citation with incorrect year");

      assertEquals(
          result.getCitation().getVolume(),
          expected.getAnnotationCitation().getVolume(),
          "Returned citation with incorrect volume");
      assertEquals(
          result.getCitation().getIssue(),
          expected.getAnnotationCitation().getIssue(),
          "Returned citation with incorrect issue");
      assertEquals(
          result.getCitation().getSummary(),
          expected.getAnnotationCitation().getSummary(),
          "Returned citation with incorrect summary");
      assertEquals(
          result.getCitation().getNote(),
          expected.getAnnotationCitation().getNote(),
          "Returned citation with incorrect note");

      if (expected.getAnnotationCitation().getCollaborativeAuthors() != null) {
        assertEqualsNoOrder(
            result.getCitation().getCollabAuthors(),
            expected.getAnnotationCitation().getCollaborativeAuthors().toArray(),
            "Returned citation with incorrect collab authors");
      } else {
        assertTrue(
            ArrayUtils.isEmpty(result.getCitation().getCollabAuthors()),
            "Returned non-empty collab authors when empty was expected");
      }
      if (expected.getAnnotationCitation().getAuthors() != null) {
        assertNotNull(
            result.getCitation().getAuthors(), "Returned null authors when authors were expected");
        assertEquals(
            result.getCitation().getAuthors().length,
            expected.getAnnotationCitation().getAuthors().size(),
            "Returned incorrect number of authors");
        for (int i = 0; i < result.getCitation().getAuthors().length; i++) {
          AuthorView actualAuthor = result.getCitation().getAuthors()[i];
          CorrectedAuthor expectedAuthor = expected.getAnnotationCitation().getAuthors().get(i);
          assertEquals(
              actualAuthor.getGivenNames(),
              expectedAuthor.getGivenNames(),
              "Author " + (i + 1) + " had incorrect given names");
          assertEquals(
              actualAuthor.getSurnames(),
              expectedAuthor.getSurName(),
              "Author " + (i + 1) + " had incorrect surnames");
          assertEquals(
              actualAuthor.getSuffix(),
              expectedAuthor.getSuffix(),
              "Author " + (i + 1) + " had incorrect suffix");
        }
      }
    }
  }
Beispiel #14
0
  protected void checkArticleInfo(
      ArticleInfo actual, Article expectedArticle, Article[] expectedRelatedArticles) {
    // basic properties
    assertEquals(
        actual.getDoi(), expectedArticle.getDoi(), "returned article info with incorrect id");
    assertEquals(
        actual.getTitle(),
        expectedArticle.getTitle(),
        "returned article info with incorrect title");
    assertEquals(
        actual.getDate(), expectedArticle.getDate(), "returned article info with incorrect date");
    assertEquals(
        actual.getDescription(), expectedArticle.getDescription(), "incorrect description");
    assertEquals(actual.getRights(), expectedArticle.getRights(), "incorrect rights");
    // check collaborative authors
    if (expectedArticle.getCollaborativeAuthors() != null) {
      assertNotNull(actual.getCollaborativeAuthors(), "returned null collaborative authors");
      assertEqualsNoOrder(
          actual.getCollaborativeAuthors().toArray(),
          expectedArticle.getCollaborativeAuthors().toArray(),
          "incorrect collaborative authors");
    }
    // check categories
    if (expectedArticle.getCategories() == null || expectedArticle.getCategories().size() == 0) {
      assertTrue(
          actual.getCategories() == null || actual.getCategories().size() == 0,
          "returned subjects when none were expected");
    } else {
      assertNotNull(actual.getCategories(), "returned null subjects");

      Set<String> collapsedCategories = new HashSet<String>(expectedArticle.getCategories().size());

      for (Category category : expectedArticle.getCategories()) {
        boolean foundCategory = false;

        collapsedCategories.add(category.getMainCategory());
        collapsedCategories.add(category.getSubCategory());

        for (ArticleCategory cat : actual.getCategories()) {
          if (cat.getMainCategory().equals(category.getMainCategory())) {
            if (cat.getSubCategory().equals(category.getSubCategory())) {
              foundCategory = true;
            }
          }
        }

        assertTrue(foundCategory, "Didn't return category: " + category.getMainCategory());
      }
    }

    // check authors
    if (expectedArticle.getAuthors() != null) {
      assertNotNull(actual.getAuthors(), "returned null list of authors");
      assertEquals(
          actual.getAuthors().size(),
          expectedArticle.getAuthors().size(),
          "returned incorrect number of authors");
      for (ArticleAuthor author : expectedArticle.getAuthors()) {
        assertTrue(
            actual.getAuthors().contains(author.getFullName()),
            "didn't return author: " + author.getFullName());
      }
    }

    // check related articles
    if (expectedRelatedArticles == null || expectedRelatedArticles.length == 0) {
      assertTrue(
          actual.getRelatedArticles() == null || actual.getRelatedArticles().size() == 0,
          "returned related articles when none were expected");
    } else {
      assertNotNull(actual.getRelatedArticles(), "returned null list of related articles");
      assertEquals(
          actual.getRelatedArticles().size(),
          expectedRelatedArticles.length,
          "returned incorrect number of related articles");
      for (Article otherArticle : expectedRelatedArticles) {
        boolean foundMatch = false;

        for (RelatedArticleInfo actualRelatedArticle : actual.getRelatedArticles()) {

          assertNotNull(otherArticle.getTitle(), "Title value of other article is null");
          assertNotNull(otherArticle.getDoi(), "DOI value of other article is null");
          assertNotNull(otherArticle.getTypes(), "Types value of other article is null");

          assertNotNull(actualRelatedArticle.getTitle(), "Title value of actual article is null");
          assertNotNull(actualRelatedArticle.getUri(), "URI value of actual article is null");
          assertNotNull(actualRelatedArticle.getTypes(), "Types value of actual article is null");

          if (otherArticle.getTitle().equals(actualRelatedArticle.getTitle())
              && otherArticle.getDoi().equals(actualRelatedArticle.getUri().toString())
              && otherArticle.getTypes().equals(actualRelatedArticle.getTypes())) {
            foundMatch = true;
            break;
          }
        }
        if (!foundMatch) {
          fail("Didn't include an entry for related article: " + otherArticle.getDoi());
        }
      }
    }
  }
Beispiel #15
0
  /**
   * Helper method to compare article properties
   *
   * @param actual - actual article
   * @param expected - article with expected properties
   */
  protected void compareArticles(Article actual, Article expected) {
    assertNotNull(actual, "returned null article");
    assertEquals(actual.getDoi(), expected.getDoi(), "Article had incorrect doi");

    assertEquals(actual.geteIssn(), expected.geteIssn(), "returned incorrect eIssn");
    assertEquals(actual.getUrl(), expected.getUrl(), "returned incorrect url");

    assertEquals(actual.getRights(), expected.getRights(), "Article had incorrect rights");
    assertEquals(actual.getLanguage(), expected.getLanguage(), "Article had incorrect language");
    assertEquals(
        actual.getPublisherLocation(),
        expected.getPublisherLocation(),
        "Article had incorrect publisher");
    assertEquals(actual.getFormat(), expected.getFormat(), "Article had incorrect format");
    assertEquals(actual.getTitle(), expected.getTitle(), "Article had incorrect Title");
    assertEquals(
        actual.getDescription(), expected.getDescription(), "Article had incorrect description");
    assertEquals(
        actual.getArchiveName(), expected.getArchiveName(), "Article had incorrect archive name");

    assertEqualsNoOrder(
        actual.getCategories().toArray(),
        expected.getCategories().toArray(),
        "Incorrect categories");

    if (expected.getAssets() != null) {
      assertEquals(
          actual.getAssets().size(), expected.getAssets().size(), "incorrect number of assets");
      for (int i = 0; i < actual.getAssets().size(); i++) {
        compareAssets(actual.getAssets().get(i), expected.getAssets().get(i));
      }
    }
    if (expected.getCitedArticles() != null) {
      assertEquals(
          actual.getCitedArticles().size(),
          expected.getCitedArticles().size(),
          "Returned incorrect number of references");
      for (int i = 0; i < actual.getCitedArticles().size(); i++) {
        compareCitedArticles(actual.getCitedArticles().get(i), expected.getCitedArticles().get(i));
      }
    } else {
      assertTrue(
          actual.getCitedArticles() == null || actual.getCitedArticles().size() == 0,
          "Returned non-empty references when none were expected");
    }

    if (expected.getAuthors() != null) {
      assertNotNull(actual.getAuthors(), "returned null author list");
      assertEquals(
          actual.getAuthors().size(),
          expected.getAuthors().size(),
          "returned incorrect number of authors");
      for (int i = 0; i < expected.getAuthors().size(); i++) {
        ArticleAuthor actualAuthor = actual.getAuthors().get(i);
        ArticleAuthor expectedAuthor = expected.getAuthors().get(i);
        assertEquals(
            actualAuthor.getFullName(),
            expectedAuthor.getFullName(),
            "Article Author had incorrect Real Name");
        assertEquals(
            actualAuthor.getGivenNames(),
            expectedAuthor.getGivenNames(),
            "Article Author had incorrect given name");
        assertEquals(
            actualAuthor.getSurnames(),
            expectedAuthor.getSurnames(),
            "Article Author had incorrect surname");
      }
    }
    if (expected.getEditors() != null) {
      assertNotNull(actual.getEditors(), "returned null editor list");
      assertEquals(
          actual.getEditors().size(),
          expected.getEditors().size(),
          "returned incorrect number of editors");
      for (int i = 0; i < expected.getEditors().size(); i++) {
        ArticleEditor actuaEditor = actual.getEditors().get(i);
        ArticleEditor expectedEditor = expected.getEditors().get(i);
        assertEquals(
            actuaEditor.getFullName(),
            expectedEditor.getFullName(),
            "Article Editor had incorrect Real Name");
        assertEquals(
            actuaEditor.getGivenNames(),
            expectedEditor.getGivenNames(),
            "Article Editor had incorrect given name");
        assertEquals(
            actuaEditor.getSurnames(),
            expectedEditor.getSurnames(),
            "Article Editor had incorrect surname");
      }
    }
    if (expected.getRelatedArticles() != null) {
      assertNotNull(actual.getRelatedArticles(), "null list of related articles");
      assertEquals(
          actual.getRelatedArticles().size(),
          expected.getRelatedArticles().size(),
          "Incorrect number of related articles");
      for (int i = 0; i < actual.getRelatedArticles().size(); i++) {
        ArticleRelationship actualRelatedArticle = actual.getRelatedArticles().get(i);
        ArticleRelationship expectedRelatedArticle = expected.getRelatedArticles().get(i);
        assertEquals(
            actualRelatedArticle.getOtherArticleDoi(),
            expectedRelatedArticle.getOtherArticleDoi(),
            "related article " + i + " had incorrect otherArticleDoi");
        assertEquals(
            actualRelatedArticle.getType(),
            expectedRelatedArticle.getType(),
            "related article " + i + " had incorrect type");
        assertTrue(
            actualRelatedArticle.getParentArticle() == actual,
            "related article had incorrect parent article");
      }
    }
  }
Beispiel #16
0
  public void testSecurityException() throws IOException {
    Path empty = testFolder.resolve("empty");
    Path triggerFile = Files.createFile(empty.resolve("SecurityException"));
    Path sampleFile = Files.createDirectories(empty.resolve("sample"));

    Path dir2 = testFolder.resolve("dir2");
    Path triggerDir = Files.createDirectories(dir2.resolve("SecurityException"));
    Files.createFile(triggerDir.resolve("fileInSE"));
    Path sample = Files.createFile(dir2.resolve("file"));

    Path triggerLink = null;
    Path linkTriggerDir = null;
    Path linkTriggerFile = null;
    if (supportsLinks) {
      Path dir = testFolder.resolve("dir");
      triggerLink = Files.createSymbolicLink(dir.resolve("SecurityException"), empty);
      linkTriggerDir = Files.createSymbolicLink(dir.resolve("lnDirSE"), triggerDir);
      linkTriggerFile = Files.createSymbolicLink(dir.resolve("lnFileSE"), triggerFile);
    }

    FaultyFileSystem.FaultyFSProvider fsp = FaultyFileSystem.FaultyFSProvider.getInstance();
    FaultyFileSystem fs = (FaultyFileSystem) fsp.newFileSystem(testFolder, null);

    try {
      fsp.setFaultyMode(false);
      Path fakeRoot = fs.getRoot();
      // validate setting
      try (Stream<Path> s = Files.list(fakeRoot.resolve("empty"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        assertEqualsNoOrder(result, new String[] {"SecurityException", "sample"});
      }

      try (Stream<Path> s = Files.walk(fakeRoot.resolve("dir2"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        assertEqualsNoOrder(result, new String[] {"dir2", "SecurityException", "fileInSE", "file"});
      }

      if (supportsLinks) {
        try (Stream<Path> s = Files.list(fakeRoot.resolve("dir"))) {
          String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
          assertEqualsNoOrder(
              result,
              new String[] {"d1", "f1", "lnDir2", "SecurityException", "lnDirSE", "lnFileSE"});
        }
      }

      // execute test
      fsp.setFaultyMode(true);
      // ignore file cause SecurityException
      try (Stream<Path> s = Files.walk(fakeRoot.resolve("empty"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        assertEqualsNoOrder(result, new String[] {"empty", "sample"});
      }
      // skip folder cause SecurityException
      try (Stream<Path> s = Files.walk(fakeRoot.resolve("dir2"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        assertEqualsNoOrder(result, new String[] {"dir2", "file"});
      }

      if (supportsLinks) {
        // not following links
        try (Stream<Path> s = Files.walk(fakeRoot.resolve("dir"))) {
          String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
          assertEqualsNoOrder(
              result, new String[] {"dir", "d1", "f1", "lnDir2", "lnDirSE", "lnFileSE"});
        }

        // following links
        try (Stream<Path> s = Files.walk(fakeRoot.resolve("dir"), FileVisitOption.FOLLOW_LINKS)) {
          String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
          // ?? Should fileInSE show up?
          // With FaultyFS, it does as no exception thrown for link to "SecurityException" with read
          // on "lnXxxSE"
          assertEqualsNoOrder(
              result,
              new String[] {
                "dir", "d1", "f1", "lnDir2", "file", "lnDirSE", "lnFileSE", "fileInSE"
              });
        }
      }

      // list instead of walk
      try (Stream<Path> s = Files.list(fakeRoot.resolve("empty"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        assertEqualsNoOrder(result, new String[] {"sample"});
      }
      try (Stream<Path> s = Files.list(fakeRoot.resolve("dir2"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        assertEqualsNoOrder(result, new String[] {"file"});
      }

      // root cause SecurityException should be reported
      try (Stream<Path> s = Files.walk(fakeRoot.resolve("dir2").resolve("SecurityException"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        fail("should not reach here due to SecurityException");
      } catch (SecurityException se) {
        assertTrue(se.getCause() instanceof FaultyFileSystem.FaultyException);
      }

      // Walk a file cause SecurityException, we should get SE
      try (Stream<Path> s = Files.walk(fakeRoot.resolve("dir").resolve("SecurityException"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        fail("should not reach here due to SecurityException");
      } catch (SecurityException se) {
        assertTrue(se.getCause() instanceof FaultyFileSystem.FaultyException);
      }

      // List a file cause SecurityException, we should get SE as cannot read attribute
      try (Stream<Path> s = Files.list(fakeRoot.resolve("dir2").resolve("SecurityException"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        fail("should not reach here due to SecurityException");
      } catch (SecurityException se) {
        assertTrue(se.getCause() instanceof FaultyFileSystem.FaultyException);
      }

      try (Stream<Path> s = Files.list(fakeRoot.resolve("dir").resolve("SecurityException"))) {
        String[] result = s.map(path -> path.getFileName().toString()).toArray(String[]::new);
        fail("should not reach here due to SecurityException");
      } catch (SecurityException se) {
        assertTrue(se.getCause() instanceof FaultyFileSystem.FaultyException);
      }
    } finally {
      // Cleanup
      if (fs != null) {
        fs.close();
      }
      if (supportsLinks) {
        Files.delete(triggerLink);
        Files.delete(linkTriggerDir);
        Files.delete(linkTriggerFile);
      }
      Files.delete(triggerFile);
      Files.delete(sampleFile);
      Files.delete(sample);
      TestUtil.removeAll(triggerDir);
    }
  }
  @Test(
      dataProvider = "basicInfo",
      dependsOnMethods = {"testExecuteNoAction"},
      alwaysRun = true)
  public void testUpdateArticleList(
      ArticleList articleList,
      Map<String, Integer> indices,
      Set<String> validDois,
      Set<String> orphanDois)
      throws Exception {
    // execute the action to get the current CSV
    action.setCommand("foo");
    action.setListKey(articleList.getListKey());
    action.execute();
    clearMessages();

    List<Article> existingArticles =
        dummyDataStore.get(ArticleList.class, articleList.getID()).getArticles();

    // move first doi to last in reorder
    String reorderedArticleCsv = action.getArticleOrderCSV();
    String articleToReorder = reorderedArticleCsv.substring(0, reorderedArticleCsv.indexOf(","));
    reorderedArticleCsv = reorderedArticleCsv.replaceFirst(articleToReorder + ",", "");
    reorderedArticleCsv += ("," + articleToReorder);
    List<String> orderedArticlesForDb = Arrays.asList(reorderedArticleCsv.split(","));
    Map<String, Integer> newIndices = new HashMap<String, Integer>();
    for (int i = 0; i < orderedArticlesForDb.size(); ++i) {
      newIndices.put(orderedArticlesForDb.get(i), i);
    }

    String displayName = "Spam";

    action.setCommand("UPDATE_LIST");
    action.setListKey(articleList.getListKey());
    action.setArticleOrderCSV(reorderedArticleCsv);
    action.setDisplayName(displayName);

    String result = action.execute();
    assertEquals(result, Action.SUCCESS, "Action didn't return success");

    assertEquals(action.getActionErrors().size(), 0, "Action returned error messages");
    assertTrue(
        action.getActionMessages().size() > 0, "Action didn't return messages indicating success");

    // check properties on action
    assertEquals(
        action.getArticleList().getListKey(),
        articleList.getListKey(),
        "action changed article list after update");
    assertEquals(action.getDisplayName(), displayName, "action had incorrect display name");

    assertEquals(
        getDois(action.getArticleList().getArticles()),
        orderedArticlesForDb,
        "Action returned wrong Dois in articleList");

    assertEquals(
        action.getArticleOrderCSV(),
        reorderedArticleCsv,
        "Action returned different articleOrderCSV");

    // the action should show the article csv in order of the valid articles
    assertEquals(
        isSorted(action.getArticleOrderCSV().split(","), newIndices),
        true,
        "Action returned wrong order after update articles");

    for (ArticleInfo articleInfo : action.getArticleInfoList()) {
      String doi = articleInfo.getDoi();
      assertEquals(
          validDois.contains(doi), true, "Action returned orphan articles in articleInfoList");
    }

    // check what got stored to the database
    ArticleList storedArticleList = dummyDataStore.get(ArticleList.class, articleList.getID());

    assertEquals(
        storedArticleList.getDisplayName(),
        displayName,
        "Article List got saved to the database with incorrect display name");

    assertEqualsNoOrder(
        storedArticleList.getArticles().toArray(),
        existingArticles.toArray(),
        "Articles got removed or added from the list on reordering");
  }