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

Skip to content
Snippets Groups Projects
Commit 0b153bb2 authored by Lorenzo Gandino's avatar Lorenzo Gandino
Browse files

add coverage to IdentityAttributeWithOwnershipMapperTest

parent d419699b
No related branches found
No related tags found
2 merge requests!106Release,!105Coverage implementation
......@@ -2,8 +2,11 @@ package com.aruba.simpl.usersroles.model.mappers;
import static com.aruba.simpl.common.test.TestUtil.a;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import com.aruba.simpl.common.model.dto.IdentityAttributeDTO;
import com.aruba.simpl.common.model.dto.IdentityAttributeWithOwnershipDTO;
import com.aruba.simpl.usersroles.model.entities.IdentityAttributeWithOwnership;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mapstruct.factory.Mappers;
......@@ -23,4 +26,68 @@ class IdentityAttributeWithOwnershipMapperTest {
entity = mapper.toEntity(null);
assertThat(entity).isNull();
}
@Test
void toEntityTest_withNullValues() {
var ia = a(IdentityAttributeWithOwnershipDTO.class);
ia.setIdentityAttribute(null);
ia.setAssignedToParticipant(null);
var entity = mapper.toEntity(ia);
assertThat(entity).isNotNull();
entity = mapper.toEntity(null);
assertThat(entity).isNull();
}
@Test
void toLightDtoWithOwnership_successMapper() {
var ia = a(IdentityAttributeWithOwnership.class);
var entity = mapper.toLightDtoWithOwnership(ia);
assertThat(entity).isNotNull();
}
@Test
void toLightDtoWithOwnership_nullEntity() {
var entity = mapper.toLightDtoWithOwnership(null);
assertThat(entity).isNull();
}
@Test
void toLightDto_successMapper() {
var ia = a(IdentityAttributeWithOwnership.class);
var entity = mapper.toLightDto(ia);
assertThat(entity).isNotNull();
}
@Test
void toLightDto_nullEntity() {
var entity = mapper.toLightDto(null);
assertThat(entity).isNull();
}
@Test
void updateIdentityAttribute_successMapper() {
var entity = new IdentityAttributeWithOwnership();
var ida = a(IdentityAttributeDTO.class);
assertDoesNotThrow(() -> mapper.updateIdentityAttribute(entity, ida));
}
@Test
void updateIdentityAttribute_withNullValues() {
var entity = new IdentityAttributeWithOwnership();
var ida = a(IdentityAttributeDTO.class);
ida.setAssignableToRoles(null);
ida.setEnabled(null);
entity.setParticipantTypes(null);
assertDoesNotThrow(() -> mapper.updateIdentityAttribute(entity, ida));
assertDoesNotThrow(() -> mapper.updateIdentityAttribute(new IdentityAttributeWithOwnership(), null));
ida.setParticipantTypes(null);
assertDoesNotThrow(() -> mapper.updateIdentityAttribute(new IdentityAttributeWithOwnership(), ida));
var entityWithNotParticipantTypes = a(IdentityAttributeWithOwnership.class);
entityWithNotParticipantTypes.setParticipantTypes(null);
assertDoesNotThrow(() -> mapper.updateIdentityAttribute(entityWithNotParticipantTypes, ida));
}
}
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