Skip to content

Commit

Permalink
Use Set to deduplicate any extra versions (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
whikloj committed Jun 9, 2022
1 parent 879f528 commit 69e1fc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Expand Up @@ -38,10 +38,10 @@
import java.net.URI;
import java.time.Instant;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

import static javax.ws.rs.core.Response.Status.METHOD_NOT_ALLOWED;
Expand Down Expand Up @@ -179,7 +179,7 @@ public Response getVersionList(@HeaderParam("Accept") final String acceptValue)
final String extUrl = identifierConverter().toDomain(externalPath());

final URI parentUri = URI.create(extUrl);
final List<Link> versionLinks = new ArrayList<>();
final Set<Link> versionLinks = new HashSet<>();
versionLinks.add(Link.fromUri(parentUri).rel("original").build());
versionLinks.add(Link.fromUri(parentUri).rel("timegate").build());
// So we don't collect the children twice, store them in an array.
Expand Down
Expand Up @@ -189,6 +189,18 @@ public void getTimeMapForContainerWithSingleVersion() throws Exception {
verifyTimemapResponse(subjectUri, id, now());
}

@Test
public void testResponseForMultipleMementosInASecond() throws Exception {
final var v1 = now();
createVersionedContainer(id);
TimeUnit.SECONDS.sleep(1);

final var v2 = now();
createMemento(subjectUri);
createMemento(subjectUri);
verifyTimemapResponse(subjectUri, id, new String[]{v1, v2}, v1, v2);
}

@Test
public void getTimeMapFromBinaryWithMultipleVersions() throws Exception {
final var v1 = now();
Expand Down

0 comments on commit 69e1fc4

Please sign in to comment.