forked from blcham/record-manager
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from akaene/record-manager-ui#37-records-export
Record manager UI#37 records export
- Loading branch information
Showing
12 changed files
with
447 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/test/java/cz/cvut/kbss/study/environment/util/ContainsSameEntities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* TermIt | ||
* Copyright (C) 2023 Czech Technical University in Prague | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package cz.cvut.kbss.study.environment.util; | ||
|
||
import cz.cvut.kbss.study.model.util.HasUri; | ||
import org.hamcrest.Description; | ||
import org.hamcrest.TypeSafeMatcher; | ||
|
||
import java.util.Collection; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Checks whether the provided collection contains the same entities as the expected one. | ||
* <p> | ||
* The membership check is done based on entity URIs. | ||
*/ | ||
public class ContainsSameEntities extends TypeSafeMatcher<Collection<? extends HasUri>> { | ||
|
||
private final Collection<? extends HasUri> expected; | ||
|
||
public ContainsSameEntities(Collection<? extends HasUri> expected) { | ||
this.expected = Objects.requireNonNull(expected); | ||
} | ||
|
||
@Override | ||
protected boolean matchesSafely(Collection<? extends HasUri> actual) { | ||
if (actual == null || actual.size() != expected.size()) { | ||
return false; | ||
} | ||
for (HasUri e : expected) { | ||
if (actual.stream().noneMatch(ee -> Objects.equals(e.getUri(), ee.getUri()))) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public void describeTo(Description description) { | ||
description.appendValueList("[", ", ", "]", expected); | ||
} | ||
|
||
public static ContainsSameEntities containsSameEntities(Collection<? extends HasUri> expected) { | ||
return new ContainsSameEntities(expected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.