Skip to content

Commit

Permalink
feat: configured mockito in PolicyToPolicyDTOTransformer test
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Fitzke committed Jul 21, 2023
1 parent 235ab2f commit 52d8fa2
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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();

Expand All @@ -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);



Expand Down

0 comments on commit 52d8fa2

Please sign in to comment.