Skip to content

Commit 5227765

Browse files
Merge pull request #204 from OpenSmock/203-Bug-on-component-instance-created-with-new-in-the-inspector
FIx #203 + tests for new Roassal inspector
2 parents e63dc65 + afe7298 commit 5227765

File tree

3 files changed

+182
-36
lines changed

3 files changed

+182
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
"
2+
A MolComponentToRoassalTest is a test class for testing the behavior of MolComponentToRoassal
3+
"
4+
Class {
5+
#name : #MolComponentToRoassalTest,
6+
#superclass : #TestCase,
7+
#category : #'Molecule-IDE-Tests-Cases'
8+
}
9+
10+
{ #category : #running }
11+
MolComponentToRoassalTest >> setUp [
12+
13+
super setUp.
14+
MolComponentManager cleanUp
15+
]
16+
17+
{ #category : #running }
18+
MolComponentToRoassalTest >> tearDown [
19+
20+
MolComponentManager cleanUp.
21+
super tearDown
22+
]
23+
24+
{ #category : #tests }
25+
MolComponentToRoassalTest >> testAssociationsAllConsumedEventsAndTargetsFor [
26+
27+
| list component |
28+
component := MolCompleteComponentImpl start.
29+
list := MolComponentToRoassal associationsAllConsumedEventsAndTargetsFor: component.
30+
self assert: list notEmpty.
31+
32+
component := MolCompleteComponentImpl new.
33+
list := MolComponentToRoassal associationsAllConsumedEventsAndTargetsFor: component.
34+
self assert: list isEmpty.
35+
]
36+
37+
{ #category : #tests }
38+
MolComponentToRoassalTest >> testAssociationsAllProducedEventsAndTargetsFor [
39+
40+
| list component |
41+
component := MolCompleteComponentImpl start.
42+
list := MolComponentToRoassal associationsAllProducedEventsAndTargetsFor: component.
43+
self assert: list notEmpty.
44+
45+
component := MolCompleteComponentImpl new.
46+
list := MolComponentToRoassal associationsAllProducedEventsAndTargetsFor: component.
47+
self assert: list notEmpty.
48+
]
49+
50+
{ #category : #tests }
51+
MolComponentToRoassalTest >> testAssociationsAllProvidedParametersAndTargetsFor [
52+
53+
| list component |
54+
component := MolCompleteComponentImpl start.
55+
list := MolComponentToRoassal associationsAllProvidedParametersAndTargetsFor: component.
56+
self assert: list notEmpty.
57+
58+
component := MolCompleteComponentImpl new.
59+
list := MolComponentToRoassal associationsAllProvidedParametersAndTargetsFor: component.
60+
self assert: list notEmpty.
61+
]
62+
63+
{ #category : #tests }
64+
MolComponentToRoassalTest >> testAssociationsAllProvidedServicesAndTargetsFor [
65+
66+
| list component |
67+
component := MolCompleteComponentImpl start.
68+
list := MolComponentToRoassal associationsAllProvidedServicesAndTargetsFor: component.
69+
self assert: list notEmpty.
70+
71+
component := MolCompleteComponentImpl new.
72+
list := MolComponentToRoassal associationsAllProvidedServicesAndTargetsFor: component.
73+
self assert: list notEmpty.
74+
]
75+
76+
{ #category : #tests }
77+
MolComponentToRoassalTest >> testAssociationsAllUsedParametersAndTargetsFor [
78+
79+
| list component |
80+
component := MolCompleteComponentImpl start.
81+
list := MolComponentToRoassal associationsAllUsedParametersAndTargetsFor: component.
82+
self assert: list notEmpty.
83+
84+
component := MolCompleteComponentImpl new.
85+
list := MolComponentToRoassal associationsAllUsedParametersAndTargetsFor: component.
86+
self assert: list isEmpty.
87+
]
88+
89+
{ #category : #tests }
90+
MolComponentToRoassalTest >> testAssociationsAllUsedServicesAndTargetsFor [
91+
92+
| list component |
93+
component := MolCompleteComponentImpl start.
94+
list := MolComponentToRoassal associationsAllUsedServicesAndTargetsFor: component.
95+
self assert: list notEmpty.
96+
97+
component := MolCompleteComponentImpl new.
98+
list := MolComponentToRoassal associationsAllUsedServicesAndTargetsFor: component.
99+
self assert: list isEmpty.
100+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"
2+
Tests on Pharo IDE features (i.e. inspector).
3+
"
4+
Class {
5+
#name : #MolPharoIDETest,
6+
#superclass : #TestCase,
7+
#category : #'Molecule-IDE-Tests-Cases'
8+
}
9+
10+
{ #category : #running }
11+
MolPharoIDETest >> setUp [
12+
13+
super setUp.
14+
MolComponentManager cleanUp
15+
]
16+
17+
{ #category : #running }
18+
MolPharoIDETest >> tearDown [
19+
20+
MolComponentManager cleanUp.
21+
super tearDown
22+
]
23+
24+
{ #category : #running }
25+
MolPharoIDETest >> testInspectComponent [
26+
27+
| component inspector |
28+
component := MolBasicComponentImpl start.
29+
self flag:'pla: this test is manual, need to test if there is an error automatically'.
30+
inspector := (Smalltalk tools inspector inspect: component).
31+
]
32+
33+
{ #category : #running }
34+
MolPharoIDETest >> testInspectComponentWithNew [
35+
36+
| component inspector |
37+
component := MolBasicComponentImpl new.
38+
self flag:'pla: this test is manual, need to test if there is an error automatically'.
39+
inspector := (Smalltalk tools inspector inspect: component).
40+
]

src/Molecule-IDE/MolComponentToRoassal.class.st

+42-36
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ Class {
1414
{ #category : #model }
1515
MolComponentToRoassal class >> associationsAllConsumedEventsAndTargetsFor: aMolComponent [
1616

17-
^ aMolComponent componentConnector eventsSubscribers associations
18-
collect: [ :asso |
19-
MolRSContractModelTarget new
20-
eventClass: asso key;
21-
name: asso value;
22-
component: aMolComponent;
23-
color: self eventColor;
24-
rsLogo: self eventLogoIn;
25-
yourself ]
17+
^ aMolComponent componentConnector
18+
ifNotNil: [ :e |
19+
e eventsSubscribers associations collect: [ :asso |
20+
MolRSContractModelTarget new
21+
eventClass: asso key;
22+
name: asso value;
23+
component: aMolComponent;
24+
color: self eventColor;
25+
rsLogo: self eventLogoIn;
26+
yourself ] ]
27+
ifNil: [ OrderedCollection new ]
2628
]
2729

2830
{ #category : #model }
@@ -67,29 +69,33 @@ MolComponentToRoassal class >> associationsAllProvidedServicesAndTargetsFor: aMo
6769
{ #category : #model }
6870
MolComponentToRoassal class >> associationsAllUsedParametersAndTargetsFor: aMolComponent [
6971

70-
^ aMolComponent componentConnector parametersProviders associations
71-
collect: [ :asso |
72-
MolRSContractModelTarget new
73-
eventClass: asso key;
74-
name: asso value;
75-
component: aMolComponent;
76-
color: self parameterColor;
77-
rsLogo: self parameterLogoIn;
78-
yourself ]
72+
^ aMolComponent componentConnector
73+
ifNotNil: [ :e |
74+
e parametersProviders associations collect: [ :asso |
75+
MolRSContractModelTarget new
76+
eventClass: asso key;
77+
name: asso value;
78+
component: aMolComponent;
79+
color: self parameterColor;
80+
rsLogo: self parameterLogoIn;
81+
yourself ] ]
82+
ifNil: [ OrderedCollection new ]
7983
]
8084

8185
{ #category : #model }
8286
MolComponentToRoassal class >> associationsAllUsedServicesAndTargetsFor: aMolComponent [
8387

84-
^ aMolComponent componentConnector servicesProviders associations
85-
collect: [ :asso |
86-
MolRSContractModelTarget new
87-
eventClass: asso key;
88-
name: asso value;
89-
component: aMolComponent;
90-
color: self serviceColor;
91-
rsLogo: self serviceLogoIn;
92-
yourself ]
88+
^ aMolComponent componentConnector
89+
ifNotNil: [ :e |
90+
e servicesProviders associations collect: [ :asso |
91+
MolRSContractModelTarget new
92+
eventClass: asso key;
93+
name: asso value;
94+
component: aMolComponent;
95+
color: self serviceColor;
96+
rsLogo: self serviceLogoIn;
97+
yourself ] ]
98+
ifNil: [ OrderedCollection new ]
9399
]
94100

95101
{ #category : #'instance creation' }
@@ -325,7 +331,7 @@ MolComponentToRoassal class >> eventColor [
325331
^ Color blue muchLighter
326332
]
327333

328-
{ #category : #'as yet unclassified' }
334+
{ #category : #resources }
329335
MolComponentToRoassal class >> eventLogo [
330336

331337
| rsLogoIn rsLogoOut |
@@ -347,7 +353,7 @@ MolComponentToRoassal class >> eventLogo [
347353
rsLogoOut }
348354
]
349355

350-
{ #category : #'as yet unclassified' }
356+
{ #category : #resources }
351357
MolComponentToRoassal class >> eventLogoIn [
352358

353359
| rsLogo |
@@ -356,7 +362,7 @@ MolComponentToRoassal class >> eventLogoIn [
356362
^ rsLogo
357363
]
358364

359-
{ #category : #'as yet unclassified' }
365+
{ #category : #resources }
360366
MolComponentToRoassal class >> eventLogoOut [
361367

362368
| rsLogo |
@@ -371,7 +377,7 @@ MolComponentToRoassal class >> parameterColor [
371377
^ Color red muchLighter
372378
]
373379

374-
{ #category : #'as yet unclassified' }
380+
{ #category : #resources }
375381
MolComponentToRoassal class >> parameterLogo [
376382

377383
| rsLogoIn rsLogoOut |
@@ -398,7 +404,7 @@ MolComponentToRoassal class >> parameterLogo [
398404
rsLogoOut }
399405
]
400406

401-
{ #category : #'as yet unclassified' }
407+
{ #category : #resources }
402408
MolComponentToRoassal class >> parameterLogoIn [
403409

404410
| rsLogo |
@@ -409,7 +415,7 @@ MolComponentToRoassal class >> parameterLogoIn [
409415
^ rsLogo
410416
]
411417

412-
{ #category : #'as yet unclassified' }
418+
{ #category : #resources }
413419
MolComponentToRoassal class >> parameterLogoOut [
414420

415421
| rsLogo |
@@ -426,7 +432,7 @@ MolComponentToRoassal class >> serviceColor [
426432
^ Color green muchLighter
427433
]
428434

429-
{ #category : #'as yet unclassified' }
435+
{ #category : #resources }
430436
MolComponentToRoassal class >> serviceLogo [
431437

432438
| rsLogoIn rsLogoOut |
@@ -455,7 +461,7 @@ MolComponentToRoassal class >> serviceLogo [
455461
rsLogoOut }
456462
]
457463

458-
{ #category : #'as yet unclassified' }
464+
{ #category : #resources }
459465
MolComponentToRoassal class >> serviceLogoIn [
460466

461467
| rsLogo |
@@ -466,7 +472,7 @@ MolComponentToRoassal class >> serviceLogoIn [
466472
^ rsLogo
467473
]
468474

469-
{ #category : #'as yet unclassified' }
475+
{ #category : #resources }
470476
MolComponentToRoassal class >> serviceLogoOut [
471477

472478
| rsLogo |

0 commit comments

Comments
 (0)