Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit a980853b authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #6: fix the datetime compare with different timezones.

Merge in EDELIVERY/smp from EDELIVERY-10341-failing-bamboo-tests to development

* commit '47541888':
  fix the datetime compare with different timezones.
parents 910d6625 47541888
No related branches found
No related tags found
No related merge requests found
Pipeline #21409 passed with warnings
package eu.europa.ec.edelivery.smp.data.dao;
import eu.europa.ec.edelivery.smp.data.model.DBDomain;
import eu.europa.ec.edelivery.smp.data.model.DBServiceGroup;
import eu.europa.ec.edelivery.smp.data.model.DBUser;
import eu.europa.ec.edelivery.smp.data.model.DBUserDeleteValidation;
......@@ -11,9 +10,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
......@@ -62,7 +59,7 @@ public class UserDaoIntegrationTest extends AbstractBaseDao {
//test
Optional<DBUser> ou = testInstance.findUserByUsername(TestConstants.USERNAME_1);
assertNotSame(u , ou.get());
assertNotSame(u, ou.get());
assertEquals(u, ou.get());
assertEquals(u.getEmailAddress(), ou.get().getEmailAddress());
assertEquals(u.getPassword(), ou.get().getPassword());
......@@ -84,7 +81,7 @@ public class UserDaoIntegrationTest extends AbstractBaseDao {
//test
Optional<DBUser> ou = testInstance.findUserByUsername(TestConstants.USERNAME_1);
assertNotSame(u , ou.get());
assertNotSame(u, ou.get());
assertEquals(u, ou.get());
assertEquals(u.getUsername(), ou.get().getUsername());
assertNull(u.getCertificate());
......@@ -100,12 +97,15 @@ public class UserDaoIntegrationTest extends AbstractBaseDao {
//test
Optional<DBUser> ou = testInstance.findUserByCertificateId(TestConstants.USER_CERT_1);
assertNotSame(u , ou.get());
assertNotSame(u, ou.get());
assertEquals(u, ou.get());
assertEquals(u.getEmailAddress(), ou.get().getEmailAddress());
assertEquals(u.getCertificate().getCertificateId(), ou.get().getCertificate().getCertificateId());
assertEquals(u.getCertificate().getValidFrom().truncatedTo(ChronoUnit.MINUTES), ou.get().getCertificate().getValidFrom().truncatedTo(ChronoUnit.MINUTES));
assertEquals(u.getCertificate().getValidTo().truncatedTo(ChronoUnit.MINUTES), ou.get().getCertificate().getValidTo().truncatedTo(ChronoUnit.MINUTES));
assertEquals(u.getCertificate().getValidFrom().toInstant(),
ou.get().getCertificate().getValidFrom().toInstant());
assertEquals(u.getCertificate().getValidTo().toInstant(),
ou.get().getCertificate().getValidTo().toInstant());
}
@Test
......@@ -118,13 +118,16 @@ public class UserDaoIntegrationTest extends AbstractBaseDao {
//test
Optional<DBUser> ou = testInstance.findUserByIdentifier(TestConstants.USER_CERT_1);
assertNotSame(u , ou.get());
assertNotSame(u, ou.get());
assertEquals(u, ou.get());
assertEquals(u.getEmailAddress(), ou.get().getEmailAddress());
assertEquals(u.getCertificate().getCertificateId(), ou.get().getCertificate().getCertificateId());
// some database timestamp objects does not store miliseconds
assertEquals(u.getCertificate().getValidFrom().truncatedTo(ChronoUnit.MINUTES), ou.get().getCertificate().getValidFrom().truncatedTo(ChronoUnit.MINUTES));
assertEquals(u.getCertificate().getValidTo().truncatedTo(ChronoUnit.MINUTES), ou.get().getCertificate().getValidTo().truncatedTo(ChronoUnit.MINUTES));
System.out.println("Zone: " + u.getCertificate().getValidFrom().toInstant());
assertEquals(u.getCertificate().getValidFrom().toInstant(),
ou.get().getCertificate().getValidFrom().toInstant());
assertEquals(u.getCertificate().getValidTo().toInstant(),
ou.get().getCertificate().getValidTo().toInstant());
}
@Test
......@@ -137,7 +140,7 @@ public class UserDaoIntegrationTest extends AbstractBaseDao {
//test
Optional<DBUser> ou = testInstance.findUserByIdentifier(TestConstants.USERNAME_TOKEN_1);
assertNotSame(u , ou.get());
assertNotSame(u, ou.get());
assertEquals(u, ou.get());
assertEquals(u.getEmailAddress(), ou.get().getEmailAddress());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment