Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Mar 19, 2024
1 parent 7c597c7 commit 17d95b8
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import com.helger.commons.ValueEnforcer;
import com.helger.commons.datetime.PDTFactory;
import com.helger.commons.equals.EqualsHelper;
import com.helger.commons.hashcode.HashCodeGenerator;
import com.helger.commons.string.ToStringGenerator;
import com.helger.diver.api.version.VESID;

Expand Down Expand Up @@ -79,6 +81,35 @@ public VESID getReplacementVESID ()
return m_aReplacementVESID;
}

@Override
public boolean equals (final Object o)
{
if (o == this)
return true;
if (o == null || !getClass ().equals (o.getClass ()))
return false;

final ValidationExecutorSetStatus rhs = (ValidationExecutorSetStatus) o;
return m_aStatusLastModDT.equals (rhs.m_aStatusLastModDT) &&
m_eType.equals (rhs.m_eType) &&
EqualsHelper.equals (m_aValidFrom, rhs.m_aValidFrom) &&
EqualsHelper.equals (m_aValidTo, rhs.m_aValidTo) &&
EqualsHelper.equals (m_sDeprecationReason, rhs.m_sDeprecationReason) &&
EqualsHelper.equals (m_aReplacementVESID, rhs.m_aReplacementVESID);
}

@Override
public int hashCode ()
{
return new HashCodeGenerator (this).append (m_aStatusLastModDT)
.append (m_eType)
.append (m_aValidFrom)
.append (m_aValidTo)
.append (m_sDeprecationReason)
.append (m_aReplacementVESID)
.getHashCode ();
}

@Override
public String toString ()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.helger.phive.api.executorset.status;

import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.helger.commons.string.StringHelper;

/**
* Test class for class {@link EValidationExecutorStatusType}.
*
* @author Philip Helger
*/
public final class EValidationExecutorStatusTypeTest
{
@Test
public void testBasic ()
{
for (final EValidationExecutorStatusType e : EValidationExecutorStatusType.values ())
{
assertTrue (StringHelper.hasText (e.getID ()));
assertSame (e, EValidationExecutorStatusType.getFromIDOrNull (e.getID ()));
}

assertNull (EValidationExecutorStatusType.getFromIDOrNull ("blafoo"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.helger.phive.api.executorset.status;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;

import java.time.OffsetDateTime;

import org.junit.Test;

import com.helger.commons.datetime.PDTFactory;
import com.helger.commons.mock.CommonsTestHelper;

/**
* Test class for class {@link ValidationExecutorSetStatus}.
*
* @author Philip Helger
*/
public final class ValidationExecutorSetStatusTest
{
@Test
public void testEmpty ()
{
final OffsetDateTime aNow = PDTFactory.getCurrentOffsetDateTimeMillisOnlyUTC ();
final ValidationExecutorSetStatus aStatus = ValidationExecutorSetStatus.createValidAt (aNow);
assertEquals (aNow, aStatus.getStatusLastModification ());
assertSame (EValidationExecutorStatusType.VALID, aStatus.getType ());
assertNull (aStatus.getValidFrom ());
assertNull (aStatus.getValidTo ());
assertNull (aStatus.getDeprecationReason ());
assertNull (aStatus.getReplacementVESID ());

CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aStatus,
ValidationExecutorSetStatus.createValidAt (aNow));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aStatus,
ValidationExecutorSetStatus.createValidAt (aNow.plusMinutes (1)));
}
}

0 comments on commit 17d95b8

Please sign in to comment.