Skip to content

Commit

Permalink
simplify test view creation and adapt to changed API in demo test pro…
Browse files Browse the repository at this point in the history
…jects
  • Loading branch information
Jan Wittler committed Feb 5, 2023
1 parent 64c5432 commit df274e6
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,20 @@ import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.change.propagation.ChangePropagationSpecificationRepository
import tools.vitruv.dsls.demo.familiespersons.families2persons.FamiliesToPersonsChangePropagationSpecification
import tools.vitruv.dsls.demo.familiespersons.families2persons.FamiliesToPersonsHelper
import tools.vitruv.dsls.demo.familiespersons.persons2families.PersonsToFamiliesChangePropagationSpecification
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProject
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.testutils.TestUserInteraction
import tools.vitruv.testutils.views.ChangePublishingTestView
import tools.vitruv.testutils.views.TestView
import tools.vitruv.testutils.views.UriMode

import static org.hamcrest.CoreMatchers.*
import static org.hamcrest.MatcherAssert.assertThat
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertThrows
import static tools.vitruv.testutils.TestModelRepositoryFactory.createTestChangeableModelRepository
import static tools.vitruv.testutils.matchers.ModelMatchers.*
import static tools.vitruv.testutils.views.ChangePublishingTestView.createDefaultChangePublishingTestView

enum MemberRole {
Father,
Expand Down Expand Up @@ -77,13 +73,7 @@ class FamiliesToPersonsTest implements TestView {
}

private def TestView prepareTestView(Path testProjectPath) throws IOException {
val userInteraction = new TestUserInteraction()
val changePropagationSpecificationProvider = new ChangePropagationSpecificationRepository(
changePropagationSpecifications)
val changeableModelRepository = createTestChangeableModelRepository(changePropagationSpecificationProvider,
userInteraction)
return new ChangePublishingTestView(testProjectPath, userInteraction, UriMode.FILE_URIS,
changeableModelRepository)
return createDefaultChangePublishingTestView(testProjectPath, changePropagationSpecifications)
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,22 @@ import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.change.propagation.ChangePropagationSpecificationRepository
import tools.vitruv.dsls.demo.familiespersons.families2persons.FamiliesToPersonsChangePropagationSpecification
import tools.vitruv.dsls.demo.familiespersons.persons2families.PersonsToFamiliesChangePropagationSpecification
import tools.vitruv.dsls.demo.familiespersons.persons2families.PersonsToFamiliesHelper
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProject
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.testutils.TestUserInteraction
import tools.vitruv.testutils.TestUserInteraction.MultipleChoiceInteractionDescription
import tools.vitruv.testutils.views.ChangePublishingTestView
import tools.vitruv.testutils.views.TestView
import tools.vitruv.testutils.views.UriMode

import static org.hamcrest.CoreMatchers.*
import static org.hamcrest.MatcherAssert.assertThat
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertThrows
import static org.junit.jupiter.api.Assertions.assertTrue
import static tools.vitruv.testutils.TestModelRepositoryFactory.createTestChangeableModelRepository
import static tools.vitruv.testutils.matchers.ModelMatchers.*
import static tools.vitruv.testutils.views.ChangePublishingTestView.createDefaultChangePublishingTestView

enum PositionPreference {
Parent,
Expand Down Expand Up @@ -79,13 +75,7 @@ class PersonsToFamiliesTest implements TestView {
}

private def TestView prepareTestView(Path testProjectPath) throws IOException {
val userInteraction = new TestUserInteraction()
val changePropagationSpecificationProvider = new ChangePropagationSpecificationRepository(
changePropagationSpecifications)
val changeableModelRepository = createTestChangeableModelRepository(changePropagationSpecificationProvider,
userInteraction)
return new ChangePublishingTestView(testProjectPath, userInteraction, UriMode.FILE_URIS,
changeableModelRepository)
return createDefaultChangePublishingTestView(testProjectPath, changePropagationSpecifications)
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,37 @@ import edu.kit.ipd.sdq.metamodels.insurance.Gender
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceClient
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceDatabase
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceFactory
import java.io.IOException
import java.nio.file.Path
import java.util.ArrayList
import java.util.List
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.xtend.lib.annotations.Accessors
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.^extension.ExtendWith
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.dsls.demo.insurancefamilies.families2insurance.FamiliesToInsuranceChangePropagationSpecification
import tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceFamiliesDefaultTestModelFactory
import tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceFamiliesTestModelFactory
import tools.vitruv.dsls.testutils.TestModel
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProject
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.testutils.views.NonTransactionalTestView

import static edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil.createFileURI
import static org.hamcrest.MatcherAssert.assertThat
import static org.junit.jupiter.api.Assertions.assertEquals
import static tools.vitruv.dsls.demo.insurancefamilies.tests.util.CreatorsUtil.createFamily
import static tools.vitruv.dsls.demo.insurancefamilies.tests.util.CreatorsUtil.createFamilyMember
import static tools.vitruv.dsls.demo.insurancefamilies.tests.util.CreatorsUtil.createInsuranceClient
import static tools.vitruv.dsls.demo.insurancefamilies.tests.util.FamiliesQueryUtil.claimFamilyRegister
import static tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceQueryUtil.claimInsuranceDatabase
import static tools.vitruv.testutils.matchers.ModelMatchers.*
import org.eclipse.emf.ecore.util.EcoreUtil
import org.junit.jupiter.api.^extension.ExtendWith
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.testutils.TestProject
import java.io.IOException
import tools.vitruv.testutils.TestUserInteraction
import tools.vitruv.change.propagation.ChangePropagationSpecificationRepository
import tools.vitruv.testutils.views.UriMode
import tools.vitruv.change.propagation.ChangePropagationSpecification
import static edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil.createFileURI
import tools.vitruv.testutils.views.NonTransactionalTestView
import tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceFamiliesDefaultTestModelFactory
import tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceFamiliesTestModelFactory
import tools.vitruv.dsls.demo.insurancefamilies.families2insurance.FamiliesToInsuranceChangePropagationSpecification
import tools.vitruv.testutils.views.ChangePublishingTestView
import tools.vitruv.dsls.testutils.TestModel
import static tools.vitruv.testutils.TestModelRepositoryFactory.createTestChangeableModelRepository
import static tools.vitruv.testutils.matchers.ModelMatchers.containsAllOf
import static tools.vitruv.testutils.matchers.ModelMatchers.equalsDeeply
import static tools.vitruv.testutils.views.ChangePublishingTestView.createDefaultChangePublishingTestView

@ExtendWith(#[TestLogging, TestProjectManager])
abstract class AbstractFamiliesToInsuranceTest {
Expand All @@ -60,13 +57,7 @@ abstract class AbstractFamiliesToInsuranceTest {
}

private def NonTransactionalTestView prepareTestView(Path testProjectPath) throws IOException {
val userInteraction = new TestUserInteraction()
val changePropagationSpecificationProvider = new ChangePropagationSpecificationRepository(
changePropagationSpecifications)
val changeableModelRepository = createTestChangeableModelRepository(changePropagationSpecificationProvider,
userInteraction)
return new ChangePublishingTestView(testProjectPath, userInteraction, UriMode.FILE_URIS,
changeableModelRepository)
return createDefaultChangePublishingTestView(testProjectPath, changePropagationSpecifications)
}

protected def Iterable<ChangePropagationSpecification> getChangePropagationSpecifications() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,46 @@ package tools.vitruv.dsls.demo.insurancefamilies.tests.insurance2families;

import edu.kit.ipd.sdq.metamodels.families.FamiliesFactory
import edu.kit.ipd.sdq.metamodels.families.Family
import edu.kit.ipd.sdq.metamodels.families.FamilyRegister
import edu.kit.ipd.sdq.metamodels.insurance.Gender
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceDatabase
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceFactory
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Path
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.xtend.lib.annotations.Accessors
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.^extension.ExtendWith
import tools.vitruv.change.interaction.UserInteractionOptions.NotificationType
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.change.propagation.ChangePropagationSpecificationRepository
import tools.vitruv.change.propagation.impl.DefaultChangeRecordingModelRepository
import tools.vitruv.dsls.demo.insurancefamilies.insurance2families.InsuranceToFamiliesChangePropagationSpecification
import tools.vitruv.dsls.demo.insurancefamilies.insurance2families.PositionPreference
import tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceFamiliesDefaultTestModelFactory
import tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceFamiliesTestModelFactory
import tools.vitruv.dsls.testutils.TestModel
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProject
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.testutils.TestUserInteraction
import tools.vitruv.testutils.TestUserInteraction.MultipleChoiceInteractionDescription
import tools.vitruv.testutils.views.ChangePublishingTestView
import tools.vitruv.testutils.views.NonTransactionalTestView
import tools.vitruv.testutils.views.UriMode

import static edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil.createFileURI
import static org.hamcrest.MatcherAssert.assertThat
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertTrue
import static tools.vitruv.dsls.demo.insurancefamilies.tests.util.CreatorsUtil.createInsuranceClient
import static tools.vitruv.dsls.demo.insurancefamilies.tests.util.FamiliesQueryUtil.claimFamilyRegister
import static tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceQueryUtil.claimInsuranceDatabase
import static tools.vitruv.testutils.matchers.ModelMatchers.*
import tools.vitruv.dsls.demo.insurancefamilies.insurance2families.PositionPreference
import org.eclipse.emf.ecore.util.EcoreUtil
import tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceFamiliesTestModelFactory
import tools.vitruv.testutils.TestProject
import java.io.IOException
import tools.vitruv.testutils.views.NonTransactionalTestView
import tools.vitruv.testutils.TestUserInteraction
import tools.vitruv.change.propagation.ChangePropagationSpecificationRepository
import tools.vitruv.testutils.views.ChangePublishingTestView
import tools.vitruv.testutils.views.UriMode
import edu.kit.ipd.sdq.metamodels.families.FamilyRegister
import tools.vitruv.dsls.demo.insurancefamilies.insurance2families.InsuranceToFamiliesChangePropagationSpecification
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.dsls.demo.insurancefamilies.tests.util.InsuranceFamiliesDefaultTestModelFactory
import static edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil.createFileURI
import org.junit.jupiter.api.^extension.ExtendWith
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.dsls.testutils.TestModel
import static tools.vitruv.testutils.TestModelRepositoryFactory.createTestChangeableModelRepository
import static tools.vitruv.testutils.matchers.ModelMatchers.equalsDeeply

enum FamilyPreference {
New,
Expand Down Expand Up @@ -74,10 +76,11 @@ abstract class AbstractInsuranceToFamiliesTest {
TestUserInteraction userInteraction) throws IOException {
val changePropagationSpecificationProvider = new ChangePropagationSpecificationRepository(
changePropagationSpecifications)
val changeableModelRepository = createTestChangeableModelRepository(changePropagationSpecificationProvider,
userInteraction)
val modelRepository = new DefaultChangeRecordingModelRepository(null, Files.createTempDirectory(null));
val changeableModelRepository = createTestChangeableModelRepository(modelRepository,
changePropagationSpecificationProvider, userInteraction)
return new ChangePublishingTestView(testProjectPath, userInteraction, UriMode.FILE_URIS,
changeableModelRepository)
changeableModelRepository, modelRepository.uuidResolver) [ modelRepository.getModelResource(it) ]
}

// === setup ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
package tools.vitruv.dsls.demo.insurancepersons.tests

import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.nio.file.Path
import tools.vitruv.dsls.demo.insurancepersons.insurance2persons.InsuranceToPersonsChangePropagationSpecification
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceFactory
import edu.kit.ipd.sdq.metamodels.insurance.Gender
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceDatabase
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceFactory
import edu.kit.ipd.sdq.metamodels.persons.PersonRegister
import edu.kit.ipd.sdq.metamodels.insurance.Gender
import edu.kit.ipd.sdq.metamodels.persons.PersonsFactory
import java.io.IOException
import java.nio.file.Path
import org.eclipse.xtend.lib.annotations.Delegate
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.^extension.ExtendWith
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.dsls.demo.insurancepersons.insurance2persons.InsuranceToPersonsChangePropagationSpecification
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProject
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.testutils.views.TestView

import static org.hamcrest.CoreMatchers.*
import static org.hamcrest.MatcherAssert.assertThat
import static org.junit.jupiter.api.Assertions.assertEquals
import static tools.vitruv.testutils.matchers.ModelMatchers.*
import tools.vitruv.testutils.views.TestView
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.testutils.TestLogging
import org.junit.jupiter.api.^extension.ExtendWith
import org.eclipse.xtend.lib.annotations.Delegate
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.testutils.TestProject
import tools.vitruv.testutils.TestUserInteraction
import tools.vitruv.change.propagation.ChangePropagationSpecificationRepository
import tools.vitruv.testutils.views.ChangePublishingTestView
import tools.vitruv.testutils.views.UriMode
import org.junit.jupiter.api.AfterEach
import java.io.IOException
import static tools.vitruv.testutils.TestModelRepositoryFactory.createTestChangeableModelRepository
import static tools.vitruv.testutils.views.ChangePublishingTestView.createDefaultChangePublishingTestView

@ExtendWith(TestLogging, TestProjectManager)
class InsuranceToPersonsTest implements TestView {
Expand All @@ -50,13 +46,7 @@ class InsuranceToPersonsTest implements TestView {
}

private def TestView prepareTestView(Path testProjectPath) throws IOException {
val userInteraction = new TestUserInteraction()
val changePropagationSpecificationProvider = new ChangePropagationSpecificationRepository(
changePropagationSpecifications)
val changeableModelRepository = createTestChangeableModelRepository(changePropagationSpecificationProvider,
userInteraction)
return new ChangePublishingTestView(testProjectPath, userInteraction, UriMode.FILE_URIS,
changeableModelRepository)
return createDefaultChangePublishingTestView(testProjectPath, changePropagationSpecifications)
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
package tools.vitruv.dsls.demo.insurancepersons.tests

import edu.kit.ipd.sdq.metamodels.persons.PersonsFactory
import edu.kit.ipd.sdq.metamodels.persons.PersonRegister
import edu.kit.ipd.sdq.metamodels.insurance.Gender
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceDatabase
import edu.kit.ipd.sdq.metamodels.insurance.InsuranceFactory
import edu.kit.ipd.sdq.metamodels.insurance.Gender
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.BeforeEach
import edu.kit.ipd.sdq.metamodels.persons.PersonRegister
import edu.kit.ipd.sdq.metamodels.persons.PersonsFactory
import java.io.IOException
import java.nio.file.Path
import org.eclipse.xtend.lib.annotations.Delegate
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.^extension.ExtendWith
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.dsls.demo.insurancepersons.persons2insurance.PersonsToInsuranceChangePropagationSpecification
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProject
import tools.vitruv.testutils.TestProjectManager
import tools.vitruv.testutils.views.TestView

import static org.hamcrest.CoreMatchers.*
import static org.hamcrest.MatcherAssert.assertThat
import static org.junit.jupiter.api.Assertions.assertEquals
import static tools.vitruv.testutils.matchers.ModelMatchers.*
import tools.vitruv.testutils.TestLogging
import tools.vitruv.testutils.TestProjectManager
import org.junit.jupiter.api.^extension.ExtendWith
import tools.vitruv.testutils.views.TestView
import org.eclipse.xtend.lib.annotations.Delegate
import tools.vitruv.change.propagation.ChangePropagationSpecification
import tools.vitruv.testutils.TestProject
import tools.vitruv.testutils.TestUserInteraction
import tools.vitruv.change.propagation.ChangePropagationSpecificationRepository
import tools.vitruv.testutils.views.UriMode
import tools.vitruv.testutils.views.ChangePublishingTestView
import org.junit.jupiter.api.AfterEach
import java.io.IOException
import static tools.vitruv.testutils.TestModelRepositoryFactory.createTestChangeableModelRepository
import static tools.vitruv.testutils.views.ChangePublishingTestView.createDefaultChangePublishingTestView

@ExtendWith(TestLogging, TestProjectManager)
class PersonsToInsuranceTest implements TestView {
Expand All @@ -50,13 +46,7 @@ class PersonsToInsuranceTest implements TestView {
}

private def TestView prepareTestView(Path testProjectPath) throws IOException {
val userInteraction = new TestUserInteraction()
val changePropagationSpecificationProvider = new ChangePropagationSpecificationRepository(
changePropagationSpecifications)
val changeableModelRepository = createTestChangeableModelRepository(changePropagationSpecificationProvider,
userInteraction)
return new ChangePublishingTestView(testProjectPath, userInteraction, UriMode.FILE_URIS,
changeableModelRepository)
return createDefaultChangePublishingTestView(testProjectPath, changePropagationSpecifications)
}

@AfterEach
Expand Down

0 comments on commit df274e6

Please sign in to comment.