package tools.vitruv.applications.pcmjava.tests.pojotransformations.java2pcm;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.palladiosimulator.pcm.repository.BasicComponent;
import org.palladiosimulator.pcm.repository.OperationInterface;
import org.palladiosimulator.pcm.repository.OperationProvidedRole;
import org.palladiosimulator.pcm.repository.Repository;

import tools.vitruv.applications.pcmjava.gplimplementation.pojotransformations.java2pcm.transformations.ClassMappingTransformation;
import tools.vitruv.applications.pcmjava.tests.util.PCM2JaMoPPTestUtils;

public class TypeReferenceMappingTransformationTest extends Java2PCMPackageMappingTransformationTest {

    @Test
    public void testAddImplementsToClassWithCorrespondingComponent() throws Throwable {
        // crete repo
        final Repository repo = this.addRepoContractsAndDatatypesPackage();
        // create class
        this.addSecondPackageCorrespondsWithoutCorrespondences();
        this.testUserInteractor.addNextSelections(ClassMappingTransformation.SELECT_CREATE_BASIC_COMPONENT);
        final BasicComponent basicComponent = this.addClassInSecondPackage(BasicComponent.class);
        this.createPackageWithPackageInfo(repo.getEntityName(), "contracts");
        // create interface
        final OperationInterface opInterface = this.createInterfaceInPackageBasedOnJaMoPPPackageWithCorrespondence("contracts",
                PCM2JaMoPPTestUtils.INTERFACE_NAME);

        // add the implement relation
        final OperationProvidedRole opr = super.addImplementsCorrespondingToOperationProvidedRoleToClass(
                basicComponent.getEntityName(), opInterface.getEntityName());

        assertEquals("The interface proivieded by the provided role is not the expected interface",
                opr.getProvidedInterface__OperationProvidedRole().getId(), opInterface.getId());
        assertEquals("The component that provides the interface is not the expected component",
                opr.getProvidingEntity_ProvidedRole().getId(), basicComponent.getId());
    }

}

@@ -70,17 +70,19 @@
 ava2pcm;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -118,17 +118,19 @@
 tEquals;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -144,16 +144,17 @@
 it.Test;
+%0D
 %0Aimport 
@@ -205,16 +205,17 @@
 mponent;
+%0D
 %0Aimport 
@@ -270,16 +270,17 @@
 terface;
+%0D
 %0Aimport 
@@ -342,65 +342,11 @@
 ole;
-%0Aimport org.palladiosimulator.pcm.repository.Repository;%0A
+%0D%0A%0D
 %0Aimp
@@ -473,16 +473,17 @@
 rmation;
+%0D
 %0Aimport 
@@ -547,17 +547,19 @@
 stUtils;
-%0A
+%0D%0A%0D
 %0Apublic 
@@ -653,17 +653,19 @@
 onTest %7B
-%0A
+%0D%0A%0D
 %0A    @Te
@@ -666,16 +666,17 @@
    @Test
+%0D
 %0A    pub
@@ -755,16 +755,17 @@
 owable %7B
+%0D
 %0A       
@@ -778,24 +778,25 @@
 ete repo
+%0D
 %0A       
  final R
@@ -791,32 +791,8 @@
     
- final Repository repo =
  thi
@@ -831,16 +831,17 @@
 ckage();
+%0D
 %0A       
@@ -856,16 +856,17 @@
 te class
+%0D
 %0A       
@@ -923,16 +923,17 @@
 ences();
+%0D
 %0A       
@@ -1033,16 +1033,17 @@
 PONENT);
+%0D
 %0A       
@@ -1136,86 +1136,9 @@
 ss);
-%0A        this.createPackageWithPackageInfo(repo.getEntityName(), %22contracts%22);
+%0D
 %0A   
@@ -1161,16 +1161,17 @@
 nterface
+%0D
 %0A       
@@ -1290,16 +1290,17 @@
 tracts%22,
+%0D
 %0A       
@@ -1344,17 +1344,19 @@
 E_NAME);
-%0A
+%0D%0A%0D
 %0A       
@@ -1385,16 +1385,17 @@
 relation
+%0D
 %0A       
@@ -1492,16 +1492,17 @@
 ToClass(
+%0D
 %0A       
@@ -1571,17 +1571,19 @@
 Name());
-%0A
+%0D%0A%0D
 %0A       
@@ -1674,16 +1674,17 @@
 erface%22,
+%0D
 %0A       
@@ -1768,24 +1768,25 @@
 ce.getId());
+%0D
 %0A        ass
@@ -1869,16 +1869,17 @@
 ponent%22,
+%0D
 %0A       
@@ -1962,14 +1962,18 @@
 ());
+%0D
 %0A    %7D
-%0A
+%0D%0A%0D
 %0A%7D
+%0D
 %0A

Remove unnecessary additional package creation in Java-PCM tests.