From afe7298c9c4ed36dc402283aad767df92f1b3de5 Mon Sep 17 00:00:00 2001 From: Pierre Laborde Date: Fri, 31 Jan 2025 12:07:15 +0100 Subject: [PATCH] FIx #203 + tests. --- .../MolComponentToRoassalTest.class.st | 100 ++++++++++++++++++ .../MolPharoIDETest.class.st | 40 +++++++ .../MolComponentToRoassal.class.st | 78 +++++++------- 3 files changed, 182 insertions(+), 36 deletions(-) create mode 100644 src/Molecule-IDE-Tests/MolComponentToRoassalTest.class.st create mode 100644 src/Molecule-IDE-Tests/MolPharoIDETest.class.st diff --git a/src/Molecule-IDE-Tests/MolComponentToRoassalTest.class.st b/src/Molecule-IDE-Tests/MolComponentToRoassalTest.class.st new file mode 100644 index 0000000..d9469bd --- /dev/null +++ b/src/Molecule-IDE-Tests/MolComponentToRoassalTest.class.st @@ -0,0 +1,100 @@ +" +A MolComponentToRoassalTest is a test class for testing the behavior of MolComponentToRoassal +" +Class { + #name : #MolComponentToRoassalTest, + #superclass : #TestCase, + #category : #'Molecule-IDE-Tests-Cases' +} + +{ #category : #running } +MolComponentToRoassalTest >> setUp [ + + super setUp. + MolComponentManager cleanUp +] + +{ #category : #running } +MolComponentToRoassalTest >> tearDown [ + + MolComponentManager cleanUp. + super tearDown +] + +{ #category : #tests } +MolComponentToRoassalTest >> testAssociationsAllConsumedEventsAndTargetsFor [ + + | list component | + component := MolCompleteComponentImpl start. + list := MolComponentToRoassal associationsAllConsumedEventsAndTargetsFor: component. + self assert: list notEmpty. + + component := MolCompleteComponentImpl new. + list := MolComponentToRoassal associationsAllConsumedEventsAndTargetsFor: component. + self assert: list isEmpty. +] + +{ #category : #tests } +MolComponentToRoassalTest >> testAssociationsAllProducedEventsAndTargetsFor [ + + | list component | + component := MolCompleteComponentImpl start. + list := MolComponentToRoassal associationsAllProducedEventsAndTargetsFor: component. + self assert: list notEmpty. + + component := MolCompleteComponentImpl new. + list := MolComponentToRoassal associationsAllProducedEventsAndTargetsFor: component. + self assert: list notEmpty. +] + +{ #category : #tests } +MolComponentToRoassalTest >> testAssociationsAllProvidedParametersAndTargetsFor [ + + | list component | + component := MolCompleteComponentImpl start. + list := MolComponentToRoassal associationsAllProvidedParametersAndTargetsFor: component. + self assert: list notEmpty. + + component := MolCompleteComponentImpl new. + list := MolComponentToRoassal associationsAllProvidedParametersAndTargetsFor: component. + self assert: list notEmpty. +] + +{ #category : #tests } +MolComponentToRoassalTest >> testAssociationsAllProvidedServicesAndTargetsFor [ + + | list component | + component := MolCompleteComponentImpl start. + list := MolComponentToRoassal associationsAllProvidedServicesAndTargetsFor: component. + self assert: list notEmpty. + + component := MolCompleteComponentImpl new. + list := MolComponentToRoassal associationsAllProvidedServicesAndTargetsFor: component. + self assert: list notEmpty. +] + +{ #category : #tests } +MolComponentToRoassalTest >> testAssociationsAllUsedParametersAndTargetsFor [ + + | list component | + component := MolCompleteComponentImpl start. + list := MolComponentToRoassal associationsAllUsedParametersAndTargetsFor: component. + self assert: list notEmpty. + + component := MolCompleteComponentImpl new. + list := MolComponentToRoassal associationsAllUsedParametersAndTargetsFor: component. + self assert: list isEmpty. +] + +{ #category : #tests } +MolComponentToRoassalTest >> testAssociationsAllUsedServicesAndTargetsFor [ + + | list component | + component := MolCompleteComponentImpl start. + list := MolComponentToRoassal associationsAllUsedServicesAndTargetsFor: component. + self assert: list notEmpty. + + component := MolCompleteComponentImpl new. + list := MolComponentToRoassal associationsAllUsedServicesAndTargetsFor: component. + self assert: list isEmpty. +] diff --git a/src/Molecule-IDE-Tests/MolPharoIDETest.class.st b/src/Molecule-IDE-Tests/MolPharoIDETest.class.st new file mode 100644 index 0000000..f11109a --- /dev/null +++ b/src/Molecule-IDE-Tests/MolPharoIDETest.class.st @@ -0,0 +1,40 @@ +" +Tests on Pharo IDE features (i.e. inspector). +" +Class { + #name : #MolPharoIDETest, + #superclass : #TestCase, + #category : #'Molecule-IDE-Tests-Cases' +} + +{ #category : #running } +MolPharoIDETest >> setUp [ + + super setUp. + MolComponentManager cleanUp +] + +{ #category : #running } +MolPharoIDETest >> tearDown [ + + MolComponentManager cleanUp. + super tearDown +] + +{ #category : #running } +MolPharoIDETest >> testInspectComponent [ + + | component inspector | + component := MolBasicComponentImpl start. + self flag:'pla: this test is manual, need to test if there is an error automatically'. + inspector := (Smalltalk tools inspector inspect: component). +] + +{ #category : #running } +MolPharoIDETest >> testInspectComponentWithNew [ + + | component inspector | + component := MolBasicComponentImpl new. + self flag:'pla: this test is manual, need to test if there is an error automatically'. + inspector := (Smalltalk tools inspector inspect: component). +] diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index b5e3110..a7bebe9 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -14,15 +14,17 @@ Class { { #category : #model } MolComponentToRoassal class >> associationsAllConsumedEventsAndTargetsFor: aMolComponent [ - ^ aMolComponent componentConnector eventsSubscribers associations - collect: [ :asso | - MolRSContractModelTarget new - eventClass: asso key; - name: asso value; - component: aMolComponent; - color: self eventColor; - rsLogo: self eventLogoIn; - yourself ] + ^ aMolComponent componentConnector + ifNotNil: [ :e | + e eventsSubscribers associations collect: [ :asso | + MolRSContractModelTarget new + eventClass: asso key; + name: asso value; + component: aMolComponent; + color: self eventColor; + rsLogo: self eventLogoIn; + yourself ] ] + ifNil: [ OrderedCollection new ] ] { #category : #model } @@ -67,29 +69,33 @@ MolComponentToRoassal class >> associationsAllProvidedServicesAndTargetsFor: aMo { #category : #model } MolComponentToRoassal class >> associationsAllUsedParametersAndTargetsFor: aMolComponent [ - ^ aMolComponent componentConnector parametersProviders associations - collect: [ :asso | - MolRSContractModelTarget new - eventClass: asso key; - name: asso value; - component: aMolComponent; - color: self parameterColor; - rsLogo: self parameterLogoIn; - yourself ] + ^ aMolComponent componentConnector + ifNotNil: [ :e | + e parametersProviders associations collect: [ :asso | + MolRSContractModelTarget new + eventClass: asso key; + name: asso value; + component: aMolComponent; + color: self parameterColor; + rsLogo: self parameterLogoIn; + yourself ] ] + ifNil: [ OrderedCollection new ] ] { #category : #model } MolComponentToRoassal class >> associationsAllUsedServicesAndTargetsFor: aMolComponent [ - ^ aMolComponent componentConnector servicesProviders associations - collect: [ :asso | - MolRSContractModelTarget new - eventClass: asso key; - name: asso value; - component: aMolComponent; - color: self serviceColor; - rsLogo: self serviceLogoIn; - yourself ] + ^ aMolComponent componentConnector + ifNotNil: [ :e | + e servicesProviders associations collect: [ :asso | + MolRSContractModelTarget new + eventClass: asso key; + name: asso value; + component: aMolComponent; + color: self serviceColor; + rsLogo: self serviceLogoIn; + yourself ] ] + ifNil: [ OrderedCollection new ] ] { #category : #'instance creation' } @@ -325,7 +331,7 @@ MolComponentToRoassal class >> eventColor [ ^ Color blue muchLighter ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> eventLogo [ | rsLogoIn rsLogoOut | @@ -347,7 +353,7 @@ MolComponentToRoassal class >> eventLogo [ rsLogoOut } ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> eventLogoIn [ | rsLogo | @@ -356,7 +362,7 @@ MolComponentToRoassal class >> eventLogoIn [ ^ rsLogo ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> eventLogoOut [ | rsLogo | @@ -371,7 +377,7 @@ MolComponentToRoassal class >> parameterColor [ ^ Color red muchLighter ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> parameterLogo [ | rsLogoIn rsLogoOut | @@ -398,7 +404,7 @@ MolComponentToRoassal class >> parameterLogo [ rsLogoOut } ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> parameterLogoIn [ | rsLogo | @@ -409,7 +415,7 @@ MolComponentToRoassal class >> parameterLogoIn [ ^ rsLogo ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> parameterLogoOut [ | rsLogo | @@ -426,7 +432,7 @@ MolComponentToRoassal class >> serviceColor [ ^ Color green muchLighter ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> serviceLogo [ | rsLogoIn rsLogoOut | @@ -455,7 +461,7 @@ MolComponentToRoassal class >> serviceLogo [ rsLogoOut } ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> serviceLogoIn [ | rsLogo | @@ -466,7 +472,7 @@ MolComponentToRoassal class >> serviceLogoIn [ ^ rsLogo ] -{ #category : #'as yet unclassified' } +{ #category : #resources } MolComponentToRoassal class >> serviceLogoOut [ | rsLogo |