Skip to content

Commit

Permalink
Fix AssertJ strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed May 13, 2024
1 parent 57b7cb7 commit a2ae73e
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,37 @@ 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
addArgument:
(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:
Expand Down

0 comments on commit a2ae73e

Please sign in to comment.