Search in sources :

Example 1 with IdmConfiguration

use of eu.bcvsolutions.idm.core.model.entity.IdmConfiguration in project CzechIdMng by bcvsolutions.

the class DefaultConfigurationServiceUnitTest method testGetValues.

@Test
public void testGetValues() {
    IdmConfiguration configurationItem = new IdmConfiguration(null, String.format("%s,%s,%s", VALUE_ONE, VALUE_TWO, VALUE_THREE));
    when(repository.findOneByName(any(String.class))).thenReturn(configurationItem);
    // 
    List<String> results = service.getValues("key");
    // 
    Assert.assertNotNull(results);
    Assert.assertEquals(3, results.size());
    Assert.assertTrue(results.stream().anyMatch(e -> e.equals(VALUE_ONE)));
    Assert.assertTrue(results.stream().anyMatch(e -> e.equals(VALUE_TWO)));
    Assert.assertTrue(results.stream().anyMatch(e -> e.equals(VALUE_THREE)));
}
Also used : InjectMocks(org.mockito.InjectMocks) IdmConfigurationRepository(eu.bcvsolutions.idm.core.model.repository.IdmConfigurationRepository) Mock(org.mockito.Mock) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Matchers.any(org.mockito.Matchers.any) Answer(org.mockito.stubbing.Answer) ModelMapper(org.modelmapper.ModelMapper) List(java.util.List) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) Lists(com.google.common.collect.Lists) Spy(org.mockito.Spy) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest) IdmConfiguration(eu.bcvsolutions.idm.core.model.entity.IdmConfiguration) Assert(org.junit.Assert) IdmConfiguration(eu.bcvsolutions.idm.core.model.entity.IdmConfiguration) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 2 with IdmConfiguration

use of eu.bcvsolutions.idm.core.model.entity.IdmConfiguration in project CzechIdMng by bcvsolutions.

the class DefaultConfigurationServiceUnitTest method testGetValuesWithEmpty.

@Test
public void testGetValuesWithEmpty() {
    IdmConfiguration configurationItem = new IdmConfiguration(null, "  , ,  ,,, ,");
    when(repository.findOneByName(any(String.class))).thenReturn(configurationItem);
    // 
    List<String> results = service.getValues("key");
    // 
    Assert.assertNotNull(results);
    Assert.assertEquals(0, results.size());
}
Also used : IdmConfiguration(eu.bcvsolutions.idm.core.model.entity.IdmConfiguration) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 3 with IdmConfiguration

use of eu.bcvsolutions.idm.core.model.entity.IdmConfiguration in project CzechIdMng by bcvsolutions.

the class DefaultConfigurationServiceUnitTest method testGetValuesWithBlankSpaces.

@Test
public void testGetValuesWithBlankSpaces() {
    IdmConfiguration configurationItem = new IdmConfiguration(null, String.format(" %s   ,%s,  %s,,,     ,", VALUE_ONE, VALUE_TWO, VALUE_THREE));
    when(repository.findOneByName(any(String.class))).thenReturn(configurationItem);
    // 
    List<String> results = service.getValues("key");
    // 
    Assert.assertNotNull(results);
    Assert.assertEquals(3, results.size());
    Assert.assertTrue(results.stream().anyMatch(e -> e.equals(VALUE_ONE)));
    Assert.assertTrue(results.stream().anyMatch(e -> e.equals(VALUE_TWO)));
    Assert.assertTrue(results.stream().anyMatch(e -> e.equals(VALUE_THREE)));
}
Also used : InjectMocks(org.mockito.InjectMocks) IdmConfigurationRepository(eu.bcvsolutions.idm.core.model.repository.IdmConfigurationRepository) Mock(org.mockito.Mock) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Matchers.any(org.mockito.Matchers.any) Answer(org.mockito.stubbing.Answer) ModelMapper(org.modelmapper.ModelMapper) List(java.util.List) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) Lists(com.google.common.collect.Lists) Spy(org.mockito.Spy) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest) IdmConfiguration(eu.bcvsolutions.idm.core.model.entity.IdmConfiguration) Assert(org.junit.Assert) IdmConfiguration(eu.bcvsolutions.idm.core.model.entity.IdmConfiguration) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Aggregations

IdmConfiguration (eu.bcvsolutions.idm.core.model.entity.IdmConfiguration)3 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)3 Test (org.junit.Test)3 Lists (com.google.common.collect.Lists)2 ConfidentialStorage (eu.bcvsolutions.idm.core.api.service.ConfidentialStorage)2 IdmConfigurationRepository (eu.bcvsolutions.idm.core.model.repository.IdmConfigurationRepository)2 List (java.util.List)2 Assert (org.junit.Assert)2 InjectMocks (org.mockito.InjectMocks)2 Matchers.any (org.mockito.Matchers.any)2 Mock (org.mockito.Mock)2 Mockito.when (org.mockito.Mockito.when)2 Spy (org.mockito.Spy)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 ModelMapper (org.modelmapper.ModelMapper)2