Code development platform for open source projects from the European Union institutions

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

update unit tests

parent ebce1081
No related branches found
No related tags found
No related merge requests found
......@@ -34,8 +34,6 @@ public class DomainDaoIntegrationTest extends AbstractBaseDao {
testUtilsDao.clearData();
}
@Rule
public ExpectedException expectedEx = ExpectedException.none();
@Test
public void persistDomain() {
......@@ -67,11 +65,10 @@ public class DomainDaoIntegrationTest extends AbstractBaseDao {
@Test
public void getTheOnlyDomainNoDomain() {
// set
expectedEx.expect(IllegalStateException.class);
expectedEx.expectMessage(ErrorCode.NO_DOMAIN.getMessage());
// execute
testInstance.getTheOnlyDomain();
IllegalStateException exception = assertThrows(IllegalStateException.class, ()->testInstance.getTheOnlyDomain());
assertEquals(ErrorCode.NO_DOMAIN.getMessage(), exception.getMessage());
}
@Test
......
......@@ -246,10 +246,6 @@ public class TestUtilsDao {
persistFlushDetach(user);
}
@Transactional
public void updateCredentials(DBCredential credential) {
merge(credential);
}
/**
* Create domain members for
......@@ -593,6 +589,7 @@ public class TestUtilsDao {
memEManager.detach(entity);
}
@Transactional
public <E> E merge(E entity) {
LOG.debug("merge entity: [{}]", entity);
return memEManager.merge(entity);
......
......@@ -21,17 +21,16 @@ import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {CredentialService.class})
@Ignore
public class CredentialServiceTest extends AbstractServiceIntegrationTest {
@Autowired
CredentialService testInstance;
@Before
public void beforeMethods() {
testUtilsDao.clearData();
testUtilsDao.createUsers();
configurationDao.refreshProperties();
}
@Test
......@@ -85,7 +84,7 @@ public class CredentialServiceTest extends AbstractServiceIntegrationTest {
public void authenticateByUsernameCredentialsInactive() {
DBCredential credential = testUtilsDao.getUser1().getUserCredentials().get(0);
credential.setActive(false);
testUtilsDao.updateCredentials(credential);
testUtilsDao.merge(credential);
// given
String username = TestConstants.USERNAME_1;
......@@ -100,7 +99,7 @@ public class CredentialServiceTest extends AbstractServiceIntegrationTest {
DBCredential credential = testUtilsDao.getUser1().getUserCredentials().get(0);
credential.setLastFailedLoginAttempt(OffsetDateTime.now());
credential.setSequentialLoginFailureCount(100);
testUtilsDao.updateCredentials(credential);
testUtilsDao.merge(credential);
// given
String username = TestConstants.USERNAME_1;
......@@ -115,7 +114,7 @@ public class CredentialServiceTest extends AbstractServiceIntegrationTest {
DBCredential credential = testUtilsDao.getUser1().getUserCredentials().get(0);
credential.setLastFailedLoginAttempt(OffsetDateTime.now().minusDays(100));
credential.setSequentialLoginFailureCount(100);
testUtilsDao.updateCredentials(credential);
testUtilsDao.merge(credential);
// given
String username = TestConstants.USERNAME_1;
......@@ -179,7 +178,7 @@ public class CredentialServiceTest extends AbstractServiceIntegrationTest {
public void authenticateByAccessTokenCredentialsInactive() {
DBCredential credential = testUtilsDao.getUser3().getUserCredentials().get(0);
credential.setActive(false);
testUtilsDao.updateCredentials(credential);
testUtilsDao.merge(credential);
// given
String accessTokenName = TestConstants.USERNAME_3_AT;
......@@ -196,7 +195,7 @@ public class CredentialServiceTest extends AbstractServiceIntegrationTest {
DBCredential credential = testUtilsDao.getUser3().getUserCredentials().get(0);
credential.setLastFailedLoginAttempt(OffsetDateTime.now());
credential.setSequentialLoginFailureCount(100);
testUtilsDao.updateCredentials(credential);
testUtilsDao.merge(credential);
// given
String accessTokenName = TestConstants.USERNAME_3_AT;
......@@ -212,7 +211,7 @@ public class CredentialServiceTest extends AbstractServiceIntegrationTest {
DBCredential credential = testUtilsDao.getUser3().getUserCredentials().get(0);
credential.setLastFailedLoginAttempt(OffsetDateTime.now().minusDays(100));
credential.setSequentialLoginFailureCount(100);
testUtilsDao.updateCredentials(credential);
testUtilsDao.merge(credential);
// given
String accessTokenName = TestConstants.USERNAME_3_AT;
......
......@@ -20,6 +20,7 @@ import eu.europa.ec.bdmsl.ws.soap.UnauthorizedFault;
import eu.europa.ec.edelivery.smp.config.SmlIntegrationConfiguration;
import eu.europa.ec.edelivery.smp.conversion.IdentifierService;
import eu.europa.ec.edelivery.smp.data.model.DBDomain;
import eu.europa.ec.edelivery.smp.data.model.doc.DBResource;
import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException;
import eu.europa.ec.edelivery.smp.sml.SmlConnector;
import org.junit.Before;
......@@ -52,11 +53,8 @@ import static org.mockito.Mockito.verify;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {SmlIntegrationConfiguration.class,
SMLIntegrationService.class})
@Ignore
public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest {
@Rule
public ExpectedException expectedExeption = ExpectedException.none();
@Autowired
IdentifierService identifierService;
......@@ -100,7 +98,6 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest {
testDomain01.setSmlRegistered(false);
testUtilsDao.merge(testDomain01);
// when
testInstance.registerDomain(testDomain01);
......@@ -127,18 +124,15 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest {
Mockito.verifyNoMoreInteractions(integrationMock.getSmpManagerClientMocks().toArray());
}
/*
@Test
public void registerParticipant() throws NotFoundFault, UnauthorizedFault, InternalErrorFault, BadRequestFault {
/* given (init database - check setup)
* Domain: TEST_DOMAIN_CODE_1
* Users: USERNAME_1, USER_CERT_2
* ServiceGroup1: TEST_SG_ID_1, TEST_SG_SCHEMA_1
* - Domain: TEST_DOMAIN_CODE_1
*
DBDomain testDomain01 = testUtilsDao.getD1();
testDomain01.setSmlRegistered(true);
DBResource resource = testUtilsDao.getResourceD1G1RD1();
resource.setSmlRegistered(false);
// when
testInstance.registerParticipant(TEST_SG_ID_1, TEST_SG_SCHEMA_1, TEST_DOMAIN_CODE_1);
testInstance.registerParticipant(resource, testDomain01);
//then -- expect on call
assertEquals(1, integrationMock.getParticipantManagmentClientMocks().size());
......@@ -146,7 +140,7 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest {
Mockito.verifyNoMoreInteractions(integrationMock.getParticipantManagmentClientMocks().toArray());
}
/*
@Test
public void registerParticipantNullScheme() throws NotFoundFault, UnauthorizedFault, InternalErrorFault, BadRequestFault {
/* given (init database - check setup)
......@@ -162,9 +156,11 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest {
assertEquals(1, integrationMock.getParticipantManagmentClientMocks().size());
verify(integrationMock.getParticipantManagmentClientMocks().get(0)).create(any());
Mockito.verifyNoMoreInteractions(integrationMock.getParticipantManagmentClientMocks().toArray());
}
/**
@Test
public void unRegisterParticipant() throws NotFoundFault, UnauthorizedFault, InternalErrorFault, BadRequestFault {
/* given (init database - check setup)
......
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