Skip to content

Commit

Permalink
Added containsVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jan 9, 2024
1 parent 618cf63 commit 676f0de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ph-diver-repo/src/main/java/com/helger/diver/repo/toc/RepoToc.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ public OffsetDateTime getLatestReleaseVersionPublicationDateTime ()
return m_aLatestReleaseVersionPubDT;
}

/**
* Check if the provided version is contained or not.
*
* @param aVersion
* The version to check. May be <code>null</code>.
* @return <code>true</code> if the version is contained, <code>false</code>
* if not.
* @since 1.1.0
*/
public boolean containsVersion (@Nullable final VESVersion aVersion)
{
return aVersion != null && m_aVersions.containsKey (aVersion);
}

@Nonnull
private EChange _addVersion (@Nonnull final VESVersion aVersion,
@Nonnull final OffsetDateTime aPublishDT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.helger.diver.repo.toc;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -62,7 +63,11 @@ public void testBasic ()
assertNull (aToC.getLatestReleaseVersionAsString ());

// 1 release version
assertFalse (aToC.containsVersion (null));
assertFalse (aToC.containsVersion (VESVersion.parseOrThrow ("1.0")));
assertTrue (aToC.addVersion (VESVersion.parseOrThrow ("1.0"), PDTFactory.getCurrentOffsetDateTime ()).isChanged ());
assertFalse (aToC.containsVersion (null));
assertTrue (aToC.containsVersion (VESVersion.parseOrThrow ("1.0")));

aVersions = aToC.getAllVersions ();
assertNotNull (aVersions);
Expand Down

0 comments on commit 676f0de

Please sign in to comment.