From a2ae73e430b3c9017ec113abae3af508f8027307 Mon Sep 17 00:00:00 2001 From: Gabriel Darbord Date: Mon, 13 May 2024 19:49:08 +0200 Subject: [PATCH] Fix AssertJ strategy --- ...mixUTAssertJJavaAssertionStrategy.class.st | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Famix-UnitTest-Exporter/FamixUTAssertJJavaAssertionStrategy.class.st b/src/Famix-UnitTest-Exporter/FamixUTAssertJJavaAssertionStrategy.class.st index 6edb13d..53531c6 100644 --- a/src/Famix-UnitTest-Exporter/FamixUTAssertJJavaAssertionStrategy.class.st +++ b/src/Famix-UnitTest-Exporter/FamixUTAssertJJavaAssertionStrategy.class.st @@ -22,9 +22,9 @@ FamixUTAssertJJavaAssertionStrategy >> dependencyImportsOn: aFamixUTExporter [ { #category : #exporting } FamixUTAssertJJavaAssertionStrategy >> export: aFamixUTAssertion on: exporter [ - "Make an assertion using AssertJ: assertThat(actual).isEqualTo(expected)" + "Make an assertion using AssertJ: assertThat(actual).{options}.isEqualTo(expected)" - | model expected assertion containsObject | + | model expected assertion | model := exporter model. expected := aFamixUTAssertion expected. assertion := model newMethodInvocation @@ -32,25 +32,27 @@ FamixUTAssertJJavaAssertionStrategy >> export: aFamixUTAssertion on: exporter [ (model newVariableExpression name: 'actual'); name: 'assertThat'. (self usingRecursiveComparison and: [ - containsObject := expected containsObject ]) ifTrue: [ - assertion := model newMethodInvocation - receiver: assertion; - name: 'usingRecursiveComparison' ]. - (self ignoringCollectionOrder and: [ expected containsCollection ]) + expected isOfObject or: [ + expected isOfCollection or: [ expected isOfDictionary ] ] ]) ifTrue: [ assertion := model newMethodInvocation receiver: assertion; - name: 'ignoringCollectionOrder' ]. - (self ignoringFieldsOfTypes isNotEmpty and: [ - containsObject ifNil: [ expected containsObject ] ]) ifTrue: [ - assertion := model newMethodInvocation - receiver: assertion; - name: 'ignoringFieldsOfTypes'; - arguments: - (ignoringFieldsOfTypes collect: [ :typeName | - model newClassProperty - type: (model newIdentifier name: typeName); - fieldName: 'class' ]) ]. + name: 'usingRecursiveComparison'. + (self ignoringCollectionOrder and: [ expected containsCollection ]) + ifTrue: [ + assertion := model newMethodInvocation + receiver: assertion; + name: 'ignoringCollectionOrder' ]. + (self ignoringFieldsOfTypes isNotEmpty and: [ + expected containsObject ]) ifTrue: [ + assertion := model newMethodInvocation + receiver: assertion; + name: 'ignoringFieldsOfTypes'; + arguments: + (ignoringFieldsOfTypes collect: [ :typeName | + model newClassProperty + type: (model newIdentifier name: typeName); + fieldName: 'class' ]) ] ]. assertion := model newMethodInvocation receiver: assertion; addArgument: