Skip to content

Commit

Permalink
feat: added wrapper:api:usecase:transformer test sekeltons
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Fitzke committed Jul 20, 2023
1 parent c3ffe1c commit d16b97d
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.sovity.edc.ext.wrapper.api.usecase.transformer;

import de.sovity.edc.ext.wrapper.api.common.model.ContractAgreementDto;
import de.sovity.edc.ext.wrapper.api.common.model.PolicyDto;
import org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreement;
import org.eclipse.edc.policy.model.*;
import org.eclipse.edc.transform.spi.TransformerContext;
import org.junit.jupiter.api.Test;

import java.util.HashMap;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

public class ContractAgreementToContractAgreementDtoTransformerTest {
private final ContractAgreementToContractAgreementDtoTransformer transformer = new ContractAgreementToContractAgreementDtoTransformer();
private final TransformerContext context = mock(TransformerContext.class);

@Test
void types() {
assertThat(transformer.getInputType()).isEqualTo(ContractAgreement.class);
assertThat(transformer.getOutputType()).isEqualTo(ContractAgreementDto.class);
}

@Test
void transform(){






}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.sovity.edc.ext.wrapper.api.usecase.transformer;

import de.sovity.edc.ext.wrapper.api.common.model.ContractAgreementDto;
import de.sovity.edc.ext.wrapper.api.usecase.model.ContractNegotiationOutputDto;
import org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreement;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation;
import org.eclipse.edc.transform.spi.TransformerContext;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

public class ContractNegotiationToContractNegotiationOutputDtoTransformerTest {
private final ContractNegotiationToContractNegotiationOutputDtoTransformer transformer = new ContractNegotiationToContractNegotiationOutputDtoTransformer();
private final TransformerContext context = mock(TransformerContext.class);

@Test
void types() {
assertThat(transformer.getInputType()).isEqualTo(ContractNegotiation.class);
assertThat(transformer.getOutputType()).isEqualTo(ContractNegotiationOutputDto.class);
}

@Test
void transform(){

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package de.sovity.edc.ext.wrapper.api.usecase.transformer;

import de.sovity.edc.ext.wrapper.api.usecase.model.ContractNegotiationOutputDto;
import de.sovity.edc.ext.wrapper.api.usecase.model.DataRequestDto;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation;
import org.eclipse.edc.connector.transfer.spi.types.DataRequest;
import org.eclipse.edc.transform.spi.TransformerContext;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

public class DataReqeustToDataRequestDtoTransformerTest {

private final DataRequestToDataRequestDtoTransformer transformer = new DataRequestToDataRequestDtoTransformer();
private final TransformerContext context = mock(TransformerContext.class);

@Test
void types() {
assertThat(transformer.getInputType()).isEqualTo(DataRequest.class);
assertThat(transformer.getOutputType()).isEqualTo(DataRequestDto.class);
}

@Test
void transform(){






}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.sovity.edc.ext.wrapper.api.usecase.transformer;

import de.sovity.edc.ext.wrapper.api.common.model.PermissionDto;
import de.sovity.edc.ext.wrapper.api.usecase.model.ContractNegotiationOutputDto;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation;
import org.eclipse.edc.policy.model.Permission;
import org.eclipse.edc.transform.spi.TransformerContext;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

public class PermissionToPermissionDtoTransformerTest {

private final PermissionToPermissionDtoTransformer transformer = new PermissionToPermissionDtoTransformer();
private final TransformerContext context = mock(TransformerContext.class);

@Test
void types() {
assertThat(transformer.getInputType()).isEqualTo(Permission.class);
assertThat(transformer.getOutputType()).isEqualTo(PermissionDto.class);
}

@Test
void transform(){

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package de.sovity.edc.ext.wrapper.api.usecase.transformer;

import de.sovity.edc.ext.wrapper.api.common.model.PolicyDto;
import org.eclipse.edc.policy.model.*;
import org.eclipse.edc.transform.spi.TransformerContext;
import org.junit.jupiter.api.Test;

import java.util.HashMap;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

public class PolicyToPolicyDtoTransformerTest {

private final PolicyToPolicyDtoTransformer transformer = new PolicyToPolicyDtoTransformer();
private final TransformerContext context = mock(TransformerContext.class);

@Test
void types() {
assertThat(transformer.getInputType()).isEqualTo(Policy.class);
assertThat(transformer.getOutputType()).isEqualTo(PolicyDto.class);
}

@Test
void transform(){

var target = "target-id";
var permission = Permission.Builder.newInstance().action(Action.Builder.newInstance().type("USE").build()).build();
var prohibition = Prohibition.Builder.newInstance().action(Action.Builder.newInstance().type("MODIFY").build()).build();
var duty = Duty.Builder.newInstance().action(Action.Builder.newInstance().type("DELETE").build()).build();
var policy = Policy.Builder.newInstance()
.permission(permission)
.prohibition(prohibition)
.duty(duty)
.assigner("assigner")
.assignee("assignee")
.inheritsFrom("inheritsFroms")
.type(PolicyType.SET)
.extensibleProperties(new HashMap<>())
.build();

var result = transformer.transform(policy,context);
//var permissionDto = result.getPermission();




assertThat(result).isNotNull();
assertThat(result.getPermission()).isNotNull();
assertThat(result.getPermission().getConstraints()).isNotNull();




}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.sovity.edc.ext.wrapper.api.usecase.transformer;

import de.sovity.edc.ext.wrapper.api.common.model.PermissionDto;
import de.sovity.edc.ext.wrapper.api.usecase.model.TransferProcessOutputDto;
import org.eclipse.edc.connector.transfer.spi.types.TransferProcess;
import org.eclipse.edc.policy.model.Permission;
import org.eclipse.edc.transform.spi.TransformerContext;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

public class TransferProcessToTransferProcessOutputDtoTransformerTest {

private final TransferProcessToTransferProcessOutputDtoTransformer transformer = new TransferProcessToTransferProcessOutputDtoTransformer();
private final TransformerContext context = mock(TransformerContext.class);

@Test
void types() {
assertThat(transformer.getInputType()).isEqualTo(TransferProcess.class);
assertThat(transformer.getOutputType()).isEqualTo(TransferProcessOutputDto.class);
}

@Test
void transform(){

}

}

0 comments on commit d16b97d

Please sign in to comment.