Skip to content
Snippets Groups Projects
Select Git revision
  • 66956ba60f87e31ed3bc3ed6161c1f695335843b
  • master default protected
  • add-frequency-to-form
  • dev protected
  • ckan-2.11.0
  • add-package-custom-fields
  • fix-adding-datasets-for-users-and-editors
  • add-auth-subroute
  • 71-migrate-custom-fields-to-ckanext-scheming
  • add-author-maintainer-information
  • fix-inline-flex-btns
  • fix-known-spatial-uri-validation
  • py3
  • 47-aktuelle-resource-einer-collection-wird-nicht-mehr-gefunden
  • 10-eingabe-der-dct-accrualperiodicity-in-weboberflache
  • v1.3
  • 2.5.3
  • 2.5.2
  • 2.5.1
  • 2.5.0
  • 2.4.7
  • 2.4.6
  • 2.4.5
  • 2.4.4
  • 2.4.3
  • 2.4.2
  • 2.4.1
  • 2.4.0
  • 2.3.1
  • 2.3.0
  • 2.2.0
  • 2.1.0
  • 2.0.0
  • 1.4.3
  • 1.4.2
  • 1.4.1
36 results

test_harvest.py

Blame
  • GroupMapperTest.java 3.29 KiB
    package de.ozgcloud.admin.keycloak;
    
    import static org.assertj.core.api.Assertions.*;
    import static org.mockito.Mockito.*;
    
    import java.util.List;
    import java.util.Map;
    import java.util.UUID;
    
    import org.junit.jupiter.api.BeforeEach;
    import org.junit.jupiter.api.Nested;
    import org.junit.jupiter.api.Test;
    import org.keycloak.representations.idm.GroupRepresentation;
    import org.mapstruct.factory.Mappers;
    import org.mockito.Spy;
    
    class GroupMapperTest {
    
    	@Spy
    	private final GroupMapper mapper = Mappers.getMapper(GroupMapper.class);
    
    	@Nested
    	class TestGetOrganisationsEinheitId {
    
    		@Test
    		void shouldReturnNullIfAttributesAreNull() {
    			var result = mapper.getOrganisationsEinheitId(null);
    
    			assertThat(result).isNull();
    		}
    
    		@Test
    		void shouldReturnNullIfAttributeIsAbsent() {
    			var result = mapper.getOrganisationsEinheitId(Map.of("dummy-attribute", List.of("123")));
    
    			assertThat(result).isNull();
    		}
    
    		@Test
    		void shouldReturnOrganisationsEinheitId() {
    			var value = GroupRepresentationTestFactory.ORGANISATIONS_EINHEIT_ID;
    			var result = mapper.getOrganisationsEinheitId(Map.of(GroupMapper.ORGANIZATIONS_EINHEIT_ID_ATTRIBUTE, List.of(value)));
    
    			assertThat(result).isEqualTo(value);
    		}
    
    		@Test
    		void shouldReturnFirstValueIfMultipleAreAvailable() {
    			var value = GroupRepresentationTestFactory.ORGANISATIONS_EINHEIT_ID;
    			var value2 = UUID.randomUUID().toString();
    
    			var result = mapper.getOrganisationsEinheitId(Map.of(GroupMapper.ORGANIZATIONS_EINHEIT_ID_ATTRIBUTE, List.of(value, value2)));
    
    			assertThat(result).isEqualTo(value);
    		}
    	}
    
    	@Nested
    	class TestFromGroupRepresentation {
    
    		private final GroupRepresentation groupRepresentation = GroupRepresentationTestFactory.create();
    
    		@BeforeEach
    		void init() {
    			doReturn(GroupRepresentationTestFactory.ORGANISATIONS_EINHEIT_ID).when(mapper).getOrganisationsEinheitId(groupRepresentation.getAttributes());
    		}
    
    		@Test
    		void shouldGetOrganisationsEinheitId() {
    			callMapper();