<commit_before>package tools.vitruv.framework.tests.change.util

import static extension tools.vitruv.framework.tests.change.util.ChangeAssertHelper.*;
import org.eclipse.emf.ecore.EObject
import tools.vitruv.framework.change.echange.eobject.CreateEObject
import tools.vitruv.framework.change.echange.EChange
import tools.vitruv.framework.change.echange.eobject.DeleteEObject
import org.eclipse.emf.ecore.EStructuralFeature
import tools.vitruv.framework.change.echange.feature.attribute.ReplaceSingleValuedEAttribute
import tools.vitruv.framework.change.echange.feature.attribute.InsertEAttributeValue
import tools.vitruv.framework.change.echange.root.InsertRootEObject
import tools.vitruv.framework.change.echange.root.RemoveRootEObject
import tools.vitruv.framework.change.echange.feature.attribute.RemoveEAttributeValue
import tools.vitruv.framework.change.echange.feature.reference.ReplaceSingleValuedEReference
import tools.vitruv.framework.change.echange.feature.reference.InsertEReference
import tools.vitruv.framework.change.echange.feature.reference.RemoveEReference
import static org.junit.Assert.*;

class AtomicEChangeAssertHelper {
	public def static assertCreateEObject(EChange change, EObject affectedEObject) {
		val createEObject = assertObjectInstanceOf(change, CreateEObject);
		createEObject.assertAffectedEObject(affectedEObject);
	}
			
	public def static assertDeleteEObject(EChange change, EObject affectedEObject) {
		val deleteEObject = assertObjectInstanceOf(change, DeleteEObject);
		deleteEObject.assertAffectedEObject(affectedEObject);
	}
	
	def public static assertInsertRootEObject(EChange change, Object expectedNewValue, String uri) {
		val insertRoot = change.assertObjectInstanceOf(InsertRootEObject)
		insertRoot.assertNewValue(expectedNewValue)
		insertRoot.assertUri(uri)
	}

	def public static assertRemoveRootEObject(EChange change, Object expectedOldValue, String uri) {
		val removeRoot = change.assertObjectInstanceOf(RemoveRootEObject)
		removeRoot.assertOldValue(expectedOldValue)
		removeRoot.assertUri(uri)
	}
	
	
	def public static assertReplaceSingleValuedEAttribute(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			Object expectedOldValue, Object expectedNewValue) {
		val removeEAttributeValue = assertObjectInstanceOf(change, ReplaceSingleValuedEAttribute)
		removeEAttributeValue.assertAffectedEObject(affectedEObject)
		removeEAttributeValue.assertAffectedEFeature(affectedFeature)
		removeEAttributeValue.assertOldValue(expectedOldValue)
		removeEAttributeValue.assertNewValue(expectedNewValue)
	}
	
	def public static assertInsertEAttribute(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			Object expectedNewValue, int expectedIndex) {
		val insertEAttributValue = assertObjectInstanceOf(change, InsertEAttributeValue)
		insertEAttributValue.assertAffectedEObject(insertEAttributValue.affectedEObject as EObject)
		insertEAttributValue.assertNewValue(expectedNewValue)
		insertEAttributValue.assertIndex(expectedIndex)
		insertEAttributValue.assertAffectedEFeature(affectedFeature)
	}
	
	def public static assertRemoveEAttribute(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			Object expectedOldValue, int expectedOldIndex) {
		val removeEAttributeValue = assertObjectInstanceOf(change, RemoveEAttributeValue)
		removeEAttributeValue.assertAffectedEObject(affectedEObject)
		removeEAttributeValue.assertAffectedEFeature(affectedFeature)
		removeEAttributeValue.assertOldValue(expectedOldValue)
		removeEAttributeValue.assertIndex(expectedOldIndex)
	}
	
	
	def static void assertReplaceSingleValuedEReference(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			Object expectedOldValue, Object expectedNewValue, boolean isContainment) {
		val replaceChange = change.assertObjectInstanceOf(ReplaceSingleValuedEReference)
		replaceChange.assertOldAndNewValue(expectedOldValue, expectedNewValue)
		replaceChange.assertAffectedEFeature(affectedFeature)
		replaceChange.assertAffectedEObject(affectedEObject)
		replaceChange.assertContainment(isContainment)
	}
	
	def static void assertSetSingleValuedEReference(EChange change,	EObject affectedEObject, EStructuralFeature affectedFeature, 
			EObject expectedNewValue, boolean isContainment, boolean isCreate) {
		val replaceChange = change.assertObjectInstanceOf(ReplaceSingleValuedEReference)
		replaceChange.assertReplaceSingleValuedEReference(affectedEObject, affectedFeature, null, expectedNewValue, isContainment);
		assertFalse(replaceChange.isFromNonDefaultValue);
		assertTrue(replaceChange.isToNonDefaultValue);
	}
		
	def static void assertUnsetSingleValuedEReference(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			EObject expectedOldValue, boolean isContainment, boolean isDelete) {
		val replaceChange = change.assertObjectInstanceOf(ReplaceSingleValuedEReference)
		replaceChange.assertReplaceSingleValuedEReference(affectedEObject, affectedFeature, expectedOldValue, null, isContainment);
		assertTrue(replaceChange.isFromNonDefaultValue);
		assertFalse(replaceChange.isToNonDefaultValue);
	}
	
	// FIXME GENERICS
	def public static <A extends EObject, T extends EObject> InsertEReference<A,T> assertInsertEReference(EChange change, A affectedEObject, 
			EStructuralFeature affectedFeature, T expectedNewValue, int expectedIndex, boolean isContainment) {
		val insertEReference = change.assertObjectInstanceOf(InsertEReference)
		insertEReference.assertAffectedEObject(affectedEObject)
		insertEReference.assertAffectedEFeature(affectedFeature)
		insertEReference.assertNewValue(expectedNewValue)
		insertEReference.assertIndex(expectedIndex)
		insertEReference.assertContainment(isContainment)
		return insertEReference
	}
	
	def public static <A extends EObject, T extends EObject> RemoveEReference<A,T> assertRemoveEReference(EChange change, A affectedEObject, 
			EStructuralFeature affectedFeature,	T expectedOldValue, int expectedOldIndex, boolean isContainment) {
		val subtractiveChange = assertObjectInstanceOf(change, RemoveEReference)
		subtractiveChange.assertAffectedEFeature(affectedFeature)
		subtractiveChange.assertAffectedEObject(affectedEObject)
		subtractiveChange.assertOldValue(expectedOldValue)
		subtractiveChange.assertIndex(expectedOldIndex)
		subtractiveChange.assertContainment(isContainment)
		return subtractiveChange<commit_msg>Remove unnecessary return values<commit_after>package tools.vitruv.framework.tests.change.util

import static extension tools.vitruv.framework.tests.change.util.ChangeAssertHelper.*;
import org.eclipse.emf.ecore.EObject
import tools.vitruv.framework.change.echange.eobject.CreateEObject
import tools.vitruv.framework.change.echange.EChange
import tools.vitruv.framework.change.echange.eobject.DeleteEObject
import org.eclipse.emf.ecore.EStructuralFeature
import tools.vitruv.framework.change.echange.feature.attribute.ReplaceSingleValuedEAttribute
import tools.vitruv.framework.change.echange.feature.attribute.InsertEAttributeValue
import tools.vitruv.framework.change.echange.root.InsertRootEObject
import tools.vitruv.framework.change.echange.root.RemoveRootEObject
import tools.vitruv.framework.change.echange.feature.attribute.RemoveEAttributeValue
import tools.vitruv.framework.change.echange.feature.reference.ReplaceSingleValuedEReference
import tools.vitruv.framework.change.echange.feature.reference.InsertEReference
import tools.vitruv.framework.change.echange.feature.reference.RemoveEReference
import static org.junit.Assert.*;

class AtomicEChangeAssertHelper {
	public def static assertCreateEObject(EChange change, EObject affectedEObject) {
		val createEObject = assertObjectInstanceOf(change, CreateEObject);
		createEObject.assertAffectedEObject(affectedEObject);
	}
			
	public def static assertDeleteEObject(EChange change, EObject affectedEObject) {
		val deleteEObject = assertObjectInstanceOf(change, DeleteEObject);
		deleteEObject.assertAffectedEObject(affectedEObject);
	}
	
	def public static assertInsertRootEObject(EChange change, Object expectedNewValue, String uri) {
		val insertRoot = change.assertObjectInstanceOf(InsertRootEObject)
		insertRoot.assertNewValue(expectedNewValue)
		insertRoot.assertUri(uri)
	}

	def public static assertRemoveRootEObject(EChange change, Object expectedOldValue, String uri) {
		val removeRoot = change.assertObjectInstanceOf(RemoveRootEObject)
		removeRoot.assertOldValue(expectedOldValue)
		removeRoot.assertUri(uri)
	}
	
	
	def public static assertReplaceSingleValuedEAttribute(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			Object expectedOldValue, Object expectedNewValue) {
		val removeEAttributeValue = assertObjectInstanceOf(change, ReplaceSingleValuedEAttribute)
		removeEAttributeValue.assertAffectedEObject(affectedEObject)
		removeEAttributeValue.assertAffectedEFeature(affectedFeature)
		removeEAttributeValue.assertOldValue(expectedOldValue)
		removeEAttributeValue.assertNewValue(expectedNewValue)
	}
	
	def public static assertInsertEAttribute(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			Object expectedNewValue, int expectedIndex) {
		val insertEAttributValue = assertObjectInstanceOf(change, InsertEAttributeValue)
		insertEAttributValue.assertAffectedEObject(insertEAttributValue.affectedEObject as EObject)
		insertEAttributValue.assertNewValue(expectedNewValue)
		insertEAttributValue.assertIndex(expectedIndex)
		insertEAttributValue.assertAffectedEFeature(affectedFeature)
	}
	
	def public static assertRemoveEAttribute(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			Object expectedOldValue, int expectedOldIndex) {
		val removeEAttributeValue = assertObjectInstanceOf(change, RemoveEAttributeValue)
		removeEAttributeValue.assertAffectedEObject(affectedEObject)
		removeEAttributeValue.assertAffectedEFeature(affectedFeature)
		removeEAttributeValue.assertOldValue(expectedOldValue)
		removeEAttributeValue.assertIndex(expectedOldIndex)
	}
	
	
	def static void assertReplaceSingleValuedEReference(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			Object expectedOldValue, Object expectedNewValue, boolean isContainment) {
		val replaceChange = change.assertObjectInstanceOf(ReplaceSingleValuedEReference)
		replaceChange.assertOldAndNewValue(expectedOldValue, expectedNewValue)
		replaceChange.assertAffectedEFeature(affectedFeature)
		replaceChange.assertAffectedEObject(affectedEObject)
		replaceChange.assertContainment(isContainment)
	}
	
	def static void assertSetSingleValuedEReference(EChange change,	EObject affectedEObject, EStructuralFeature affectedFeature, 
			EObject expectedNewValue, boolean isContainment, boolean isCreate) {
		val replaceChange = change.assertObjectInstanceOf(ReplaceSingleValuedEReference)
		replaceChange.assertReplaceSingleValuedEReference(affectedEObject, affectedFeature, null, expectedNewValue, isContainment);
		assertFalse(replaceChange.isFromNonDefaultValue);
		assertTrue(replaceChange.isToNonDefaultValue);
	}
		
	def static void assertUnsetSingleValuedEReference(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			EObject expectedOldValue, boolean isContainment, boolean isDelete) {
		val replaceChange = change.assertObjectInstanceOf(ReplaceSingleValuedEReference)
		replaceChange.assertReplaceSingleValuedEReference(affectedEObject, affectedFeature, expectedOldValue, null, isContainment);
		assertTrue(replaceChange.isFromNonDefaultValue);
		assertFalse(replaceChange.isToNonDefaultValue);
	}
	
	// FIXME GENERICS
	def public static void assertInsertEReference(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature, 
			EObject expectedNewValue, int expectedIndex, boolean isContainment) {
		val insertEReference = change.assertObjectInstanceOf(InsertEReference)
		insertEReference.assertAffectedEObject(affectedEObject)
		insertEReference.assertAffectedEFeature(affectedFeature)
		insertEReference.assertNewValue(expectedNewValue)
		insertEReference.assertIndex(expectedIndex)
		insertEReference.assertContainment(isContainment)
	}
	
	def public static void assertRemoveEReference(EChange change, EObject affectedEObject, EStructuralFeature affectedFeature,
			EObject expectedOldValue, int expectedOldIndex, boolean isContainment) {
		val subtractiveChange = assertObjectInstanceOf(change, RemoveEReference)
		subtractiveChange.assertAffectedEFeature(affectedFeature)
		subtractiveChange.assertAffectedEObject(affectedEObject)
		subtractiveChange.assertOldValue(expectedOldValue)
		subtractiveChange.assertIndex(expectedOldIndex)
		subtractiveChange.assertContainment(isContainment)
{'fraction_non_alphanumeric': 0.05998272748684934, 'fraction_numerical': 0.0, 'mean_word_length': 8.836293436293436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5837922', 'n_tokens_mistral': 3756, 'n_tokens_neox': 3448, 'n_words': 574}