From 52d8fa26166987bd184ff7fd672786a54077be79 Mon Sep 17 00:00:00 2001 From: Martin Fitzke Date: Fri, 21 Jul 2023 14:59:15 +0200 Subject: [PATCH] feat: configured mockito in PolicyToPolicyDTOTransformer test --- .../PolicyToPolicyDtoTransformerTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/extensions/wrapper/wrapper/src/test/java/de/sovity/edc/ext/wrapper/api/usecase/transformer/PolicyToPolicyDtoTransformerTest.java b/extensions/wrapper/wrapper/src/test/java/de/sovity/edc/ext/wrapper/api/usecase/transformer/PolicyToPolicyDtoTransformerTest.java index 98ba99fae..2d921a99d 100644 --- a/extensions/wrapper/wrapper/src/test/java/de/sovity/edc/ext/wrapper/api/usecase/transformer/PolicyToPolicyDtoTransformerTest.java +++ b/extensions/wrapper/wrapper/src/test/java/de/sovity/edc/ext/wrapper/api/usecase/transformer/PolicyToPolicyDtoTransformerTest.java @@ -1,5 +1,7 @@ package de.sovity.edc.ext.wrapper.api.usecase.transformer; +import de.sovity.edc.ext.wrapper.api.common.model.ExpressionDto; +import de.sovity.edc.ext.wrapper.api.common.model.PermissionDto; import de.sovity.edc.ext.wrapper.api.common.model.PolicyDto; import org.eclipse.edc.policy.model.*; import org.eclipse.edc.transform.spi.TransformerContext; @@ -8,8 +10,7 @@ import java.util.HashMap; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.*; public class PolicyToPolicyDtoTransformerTest { @@ -40,6 +41,11 @@ void transform(){ .extensibleProperties(new HashMap<>()) .build(); + + var pmDto = new PermissionDto(new ExpressionDto()); + when(context.transform(any(Permission.class), eq(PermissionDto.class))).thenReturn(pmDto); + // or when(context.transform(permission, PermissionDto.class)).thenReturn(new PermissionDto()); + var result = transformer.transform(policy,context); //var permissionDto = result.getPermission(); @@ -49,7 +55,9 @@ void transform(){ assertThat(result).isNotNull(); assertThat(result.getPermission()).isNotNull(); assertThat(result.getPermission().getConstraints()).isNotNull(); + assertThat(result.getPermission()).isEqualTo(pmDto); + verify(context).transform(permission, PermissionDto.class);