-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMolComponentImplTest.class.st
More file actions
761 lines (548 loc) · 27.9 KB
/
MolComponentImplTest.class.st
File metadata and controls
761 lines (548 loc) · 27.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
Class {
#name : #MolComponentImplTest,
#superclass : #TestCase,
#category : #'Molecule-Tests-Cases'
}
{ #category : #running }
MolComponentImplTest >> setUp [
MolComponentManager cleanUp.
super setUp
]
{ #category : #running }
MolComponentImplTest >> tearDown [
super tearDown.
MolComponentManager cleanUp
]
{ #category : #tests }
MolComponentImplTest >> testAugmentedClassToAComponentProperties [
| component |
component := MolAugmentedClassToAComponentWithoutType new.
self assert: component class isComponentClass.
self assert: component class haveComponentType equals: false.
"Component name"
self assert: component componentName equals: nil.
component componentName: MolUtils defaultComponentName.
self assert: component componentName equals: MolUtils defaultComponentName.
"Component connector, just test if accessors exists because componentConnector is managed on component instanciation"
self assert: component componentConnector equals: nil.
component componentConnector: nil.
self assert: component componentConnector equals: nil.
]
{ #category : #tests }
MolComponentImplTest >> testAugmentedClassToAComponentRemoveAndReuseAsNormalWay [
"Use an existing class to a component, remove the component and reuse the instance as a normal way"
| myInstance |
"Start the component"
myInstance := MolUtils startComponent: MolAugmentedClassToAComponent.
self assert: myInstance service equals: #service2.
self assert: myInstance parameter equals: #parameter2.
"Stop the component but after use instance as a normal way"
MolUtils stopComponent: MolAugmentedClassToAComponent.
"Use classic methods wich uses component methods and check if no errors are rising in case of using these methods in the classic implementation"
self assert: myInstance existingInterfaceA.
self assert: myInstance existingInterfaceB.
self assert: myInstance existingInterfaceC.
myInstance getMolUsedEventsSubscriber subscribe: myInstance.
myInstance getMolUsedEventsSubscriber unsubscribe: myInstance.
]
{ #category : #tests }
MolComponentImplTest >> testAugmentedClassToAComponentUsesAsAClassicWay [
"Use existing API outside a Component system but with component capacities use inside (get services, parameters and notify events)"
| myInstance |
myInstance := MolAugmentedClassToAComponent new.
self assert: myInstance existingInterfaceA.
self assert: myInstance existingInterfaceB.
self assert: myInstance existingInterfaceC.
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testChangeEventsProducersDuringSubscribe [
| component |
component := MolCompleteComponentImpl start: #myComponent.
component getMolUsedEventsSubscriber subscribe: component.
"Change events producers"
component forEvents: MolUsedEvents addProducer: #componentA.
]
{ #category : #'tests - contract' }
MolComponentImplTest >> testComponentType [
self assert: MolBasicComponentImpl componentType equals: MolBasicComponent.
self assert: MolBasicSubComponentImpl componentType equals: MolBasicComponent.
]
{ #category : #'tests - contract' }
MolComponentImplTest >> testComponentType2 [
self assert: MolComponentImpl componentType equals: nil.
self assert: MolCompleteComponentImpl componentType equals: MolCompleteComponent.
self assert: MolTestComponentImplA componentType equals: nil.
"inheritance"
self assert: MolCompleteComponentChildImpl componentType equals: MolCompleteComponentChild.
]
{ #category : #tests }
MolComponentImplTest >> testDefineComponent [
self assert: MolComponentImpl defineComponent equals: MolComponentImpl.
]
{ #category : #tests }
MolComponentImplTest >> testEventsNotifiers [
| component |
component := MolCompleteComponentImpl new.
self assert: component eventsNotifiers isEmpty.
component := MolUtils deployAndInitializeComponent: MolCompleteComponentImpl named: #myComponentA.
"Test initial events producer contents : default component name"
self assert: component eventsNotifiers size equals: 1.
self assert: ((component eventsNotifiers at: MolUsedEvents) isKindOf: MolEventNotifier).
MolUtils activateComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component eventsNotifiers size equals: 1.
self assert: ((component eventsNotifiers at: MolUsedEvents) isKindOf: MolEventNotifier).
MolUtils passivateComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component eventsNotifiers size equals: 1.
self assert: ((component eventsNotifiers at: MolUsedEvents) isKindOf: MolEventNotifier).
MolUtils removeComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component eventsNotifiers isEmpty.
]
{ #category : #tests }
MolComponentImplTest >> testEventsSubscribers [
| component |
component := MolCompleteComponentImpl new.
self assert: component eventsSubscribers isEmpty.
component := MolUtils deployAndInitializeComponent: MolCompleteComponentImpl named: #myComponentA.
"Test initial events producer contents : default component name"
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: MolUtils defaultComponentName.
MolUtils activateComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: MolUtils defaultComponentName.
MolUtils passivateComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: MolUtils defaultComponentName.
MolUtils removeComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component eventsSubscribers isEmpty.
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testForEventsAddAllProducers [
| component |
component := MolCompleteComponentImpl start: #myComponentA.
component forEvents: MolUsedEvents addAllProducers: #(#producerA #producerB #producerC).
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#default #producerA #producerB #producerC).
component forEvents: MolUsedEvents addAllProducers: #(#producerA #producerB #producerC #producerD #producerE #producerF).
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#default #producerA #producerB #producerC #producerD #producerE #producerF).
]
{ #category : #tests }
MolComponentImplTest >> testForEventsAddProducer [
| component |
component := MolCompleteComponentImpl start: #myComponentA.
component forEvents: MolUsedEvents addProducer: #producerA.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#default #producerA).
component forEvents: MolUsedEvents addProducer: #producerB.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#default #producerA #producerB).
component forEvents: MolUsedEvents addProducer: MolUtils defaultComponentName.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#default #producerA #producerB).
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testForEventsRemoveAllProducers [
| component |
component := MolCompleteComponentImpl start: #myComponentA.
component forEvents: MolUsedEvents addAllProducers: #(#producerA #producerB #producerC).
component forEvents: MolUsedEvents removeAllProducers: #(#producerA #producerB #producerC #producerD #producerE #producerF).
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: MolUtils defaultComponentName.
component forEvents: MolUsedEvents addAllProducers: #(#producerA #producerB #producerC).
component forEvents: MolUsedEvents removeAllProducers: #(#producerA).
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#default #producerB #producerC).
component forEvents: MolUsedEvents removeAllProducers: #(#default #producerB #producerC).
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: MolUtils defaultComponentName. "Cannot remove the component default name"
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testForEventsRemoveProducer [
| component |
component := MolCompleteComponentImpl start: #myComponentA.
component forEvents: MolUsedEvents useAllProducers: #(#producerA #producerB #producerC).
component forEvents: MolUsedEvents removeProducer: #producerA.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#producerB #producerC).
component forEvents: MolUsedEvents removeProducer: #producerB.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #producerC.
component forEvents: MolUsedEvents removeProducer: #producerC.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: nil.
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testForEventsRemoveProducer2 [
"This test testing if case of remove a producer with the defaultComponentName, it is not done because of this is the basic configuration of a component event"
| component |
component := MolCompleteComponentImpl start: #myComponentA.
component forEvents: MolUsedEvents removeProducer: MolUtils defaultComponentName.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: MolUtils defaultComponentName.
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testForEventsUseAllProducers [
| component |
component := MolCompleteComponentImpl start: #myComponentA.
component forEvents: MolUsedEvents useAllProducers: #(#producerA #producerB #producerC).
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#producerA #producerB #producerC).
component forEvents: MolUsedEvents useAllProducers: #(#producerD #producerE #producerF).
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #(#producerD #producerE #producerF).
component forEvents: MolUsedEvents useAllProducers: #().
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: nil.
component forEvents: MolUsedEvents useAllProducers: nil.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: nil.
component forEvents: MolUsedEvents useAllProducers: #(#producerA).
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #producerA.
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testForEventsUseProducer [
| component |
component := MolCompleteComponentImpl start: #myComponentA.
"Test set a specific producer"
component forEvents: MolUsedEvents useProducer: #producerA.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #producerA.
component forEvents: MolUsedEvents useProducer: #producerB.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #producerB.
component forEvents: MolUsedEvents useProducer: nil.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: nil.
component forEvents: MolUsedEvents useProducer: MolUtils defaultComponentName.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: MolUtils defaultComponentName.
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testForEventsUseProducer2 [
| component |
component := MolCompleteComponentImpl start: #myComponentA.
component forEvents: MolUsedEvents useAllProducers: #(#producerA #producerB #producerC).
component forEvents: MolUsedEvents useProducer: #producerD.
self assert: component eventsSubscribers size equals: 1.
self assert: (component eventsSubscribers at: MolUsedEvents) equals: #producerD.
]
{ #category : #tests }
MolComponentImplTest >> testGetComponentUsedWithWrongName [
"Connect two components with different types of component name"
| providerComponent userComponent |
providerComponent := MolCompleteComponentImpl start: #myComponentName.
userComponent := MolCompleteComponent2Impl start.
userComponent forServices: MolUsedServices useProvider: #badComponentName.
userComponent forParameters: MolUsedParameters useProvider: #badComponentName.
self assert: userComponent getMolUsedServicesProvider isNotFoundServices.
self assert: userComponent getMolUsedParametersProvider isNotFoundParameters.
userComponent forServices: MolUsedServices useProvider: 'myComponentName'.
userComponent forParameters: MolUsedParameters useProvider: 'myComponentName'.
self assert: userComponent getMolUsedServicesProvider isNotFoundServices.
self assert: userComponent getMolUsedParametersProvider isNotFoundParameters.
userComponent forServices: MolUsedServices useProvider: 29.
userComponent forParameters: MolUsedParameters useProvider: 29.
self assert: userComponent getMolUsedServicesProvider isNotFoundServices.
self assert: userComponent getMolUsedParametersProvider isNotFoundParameters.
userComponent forServices: MolUsedServices useProvider: (OrderedCollection new).
userComponent forParameters: MolUsedParameters useProvider: (OrderedCollection new).
self assert: userComponent getMolUsedServicesProvider isNotFoundServices.
self assert: userComponent getMolUsedParametersProvider isNotFoundParameters.
userComponent forServices: MolUsedServices useProvider: nil.
userComponent forParameters: MolUsedParameters useProvider: nil.
self assert: userComponent getMolUsedServicesProvider isNotFoundServices.
self assert: userComponent getMolUsedParametersProvider isNotFoundParameters.
userComponent forServices: MolUsedServices useProvider: #myComponentName.
userComponent forParameters: MolUsedParameters useProvider: #myComponentName.
self assert: userComponent getMolUsedServicesProvider isNotFoundServices not.
self assert: userComponent getMolUsedParametersProvider isNotFoundParameters not.
]
{ #category : #'tests - contract' }
MolComponentImplTest >> testHaveComponentType [
self assert: MolComponentImpl haveComponentType equals: false.
self assert: MolBasicComponentImpl haveComponentType equals: true.
self assert: MolBasicSubComponentImpl haveComponentType equals: true.
]
{ #category : #'tests - contract' }
MolComponentImplTest >> testHaveOwnComponentType [
self assert: MolComponentImpl haveOwnComponentType equals: false.
self assert: MolBasicComponentImpl haveOwnComponentType equals: true.
self assert: MolBasicSubComponentImpl haveOwnComponentType equals: false.
]
{ #category : #tests }
MolComponentImplTest >> testIsComponentClass [
self deny: MolComponentImpl isComponentClass. "This class is not a component class, but users yes"
]
{ #category : #tests }
MolComponentImplTest >> testIsFoundEventsNotifier [
| component |
component := MolUtils startComponent: MolCompleteComponentImpl.
self assert: component getMolUsedEventsNotifier isFoundEventsNotifier.
self assert: component getMolUsedEventsNotifier isNotFoundEventsNotifier not.
]
{ #category : #tests }
MolComponentImplTest >> testIsFoundEventsSubscriber [
| component |
component := MolUtils startComponent: MolCompleteComponentImpl.
self assert: component getMolUsedEventsSubscriber isFoundEventsSubscriber.
self assert: component getMolUsedEventsSubscriber isNotFoundEventsSubscriber not.
]
{ #category : #tests }
MolComponentImplTest >> testIsFoundParameters [
| component |
component := MolUtils startComponent: MolCompleteComponentImpl.
self assert: component getMolUsedParametersProvider isFoundParameters.
self assert: component getMolUsedParametersProvider isNotFoundParameters not.
]
{ #category : #tests }
MolComponentImplTest >> testIsFoundServices [
| component |
component := MolUtils startComponent: MolCompleteComponentImpl.
self assert: component getMolUsedServicesProvider isFoundServices.
self assert: component getMolUsedServicesProvider isNotFoundServices not.
]
{ #category : #tests }
MolComponentImplTest >> testIsNotFoundEventsNotifier [
| component result |
component := MolCompleteComponentImpl new.
self assert: component getMolUsedEventsNotifier isNotFoundEventsNotifier.
self assert: component getMolUsedEventsNotifier isFoundEventsNotifier not.
result := component getMolUsedEventsNotifier event.
self assert: result isNil.
]
{ #category : #tests }
MolComponentImplTest >> testIsNotFoundParameters [
| component result |
component := MolCompleteComponentImpl new.
self assert: component getMolUsedParametersProvider isNotFoundParameters.
self assert: component getMolUsedParametersProvider isFoundParameters not.
result := component getMolUsedParametersProvider parameter.
self assert: result isNil.
]
{ #category : #tests }
MolComponentImplTest >> testIsNotFoundServices [
| component result |
component := MolCompleteComponentImpl new.
self assert: component getMolUsedServicesProvider isNotFoundServices.
self assert: component getMolUsedServicesProvider isFoundServices not.
result := component getMolUsedServicesProvider service.
self assert: result isNil.
]
{ #category : #tests }
MolComponentImplTest >> testIsNotFoundSubscriber [
| component |
component := MolCompleteComponentImpl new.
self assert: component getMolUsedEventsSubscriber isNotFoundEventsSubscriber.
self assert: component getMolUsedEventsSubscriber isFoundEventsSubscriber not.
component getMolUsedEventsSubscriber subscribe: self.
component getMolUsedEventsSubscriber unsubscribe: self.
]
{ #category : #'tests - contract' }
MolComponentImplTest >> testIsOverrideComponentType [
self assert: MolCompleteComponentImpl isOverrideComponentType equals: false.
self assert: MolCompleteComponentChildImpl isOverrideComponentType equals: true.
self assert: MolBasicComponentImpl isOverrideComponentType equals: false.
self assert: MolBasicSubComponentImpl isOverrideComponentType equals: false.
]
{ #category : #tests }
MolComponentImplTest >> testIsSubscribed [
| component |
component := MolCompleteComponentImpl start.
self assert: (component isSubscribed: MolUsedEvents) equals: false. "can be true when subscribe"
self assert: (component isSubscribed: MolUsedChildEvents) equals: false. "never be true"
component getMolUsedEventsSubscriber subscribe: component.
self assert: (component isSubscribed: MolUsedEvents) equals: true.
self assert: (component isSubscribed: MolUsedChildEvents) equals: false. "never be true"
component getMolUsedEventsSubscriber unsubscribe: component.
self assert: (component isSubscribed: MolUsedEvents) equals: false.
self assert: (component isSubscribed: MolUsedChildEvents) equals: false. "never be true"
component getMolUsedEventsSubscriber subscribe: component.
self assert: (component isSubscribed: MolUsedEvents) equals: true.
self assert: (component isSubscribed: MolUsedChildEvents) equals: false. "never be true"
MolCompleteComponentImpl stop.
self assert: (component isSubscribed: MolUsedEvents) equals: false.
self assert: (component isSubscribed: MolUsedChildEvents) equals: false. "never be true"
]
{ #category : #'tests - contract' }
MolComponentImplTest >> testOverridedComponentTypes [
self assert: MolCompleteComponentImpl overridedComponentTypes isEmpty.
self assert: MolCompleteComponentChildImpl overridedComponentTypes size equals: 1.
self assert: MolCompleteComponentChildImpl overridedComponentTypes first equals: MolCompleteComponent.
]
{ #category : #'tests - contract' }
MolComponentImplTest >> testOwnComponentType [
self assert: MolBasicComponentImpl ownComponentType equals: MolBasicComponent.
self assert: MolBasicSubComponentImpl ownComponentType equals: nil.
]
{ #category : #tests }
MolComponentImplTest >> testParametersDoIfNone [
"First: with found services"
| component exception |
component := MolUtils startComponent: MolCompleteComponentImpl.
component getMolUsedParametersProvider parametersDo: [ :s |
self assert: s isFoundParameters.
self assert: s parameter equals: #parameter.
] ifNone: [ self fail ].
"Second: with not found services"
component := MolCompleteComponentImpl new.
component getMolUsedParametersProvider parametersDo: [ :s | self fail ] ifNone: [
exception := true.
].
self assert: exception.
]
{ #category : #tests }
MolComponentImplTest >> testParametersProviders [
| component |
component := MolCompleteComponentImpl new.
self assert: component parametersProviders isEmpty.
component := MolUtils deployAndInitializeComponent: MolCompleteComponentImpl named: #myComponentA.
"Test initial events producer contents : default component name"
self assert: component parametersProviders size equals: 1.
self assert: (component parametersProviders at: MolUsedParameters) equals: MolUtils defaultComponentName.
MolUtils activateComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component parametersProviders size equals: 1.
self assert: (component parametersProviders at: MolUsedParameters) equals: MolUtils defaultComponentName.
MolUtils passivateComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component parametersProviders size equals: 1.
self assert: (component parametersProviders at: MolUsedParameters) equals: MolUtils defaultComponentName.
MolUtils removeComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component parametersProviders isEmpty.
]
{ #category : #'tests - connecting - events producers' }
MolComponentImplTest >> testSendEventInAForkDuringCleanUp [
| component |
component := MolCompleteComponentForkedImpl start.
self assert: component thread isRunning.
10 milliSecond wait.
MolComponentManager cleanUp.
"waiting for thread loop"
5 second wait. "here no error"
self deny: component thread isRunning
]
{ #category : #tests }
MolComponentImplTest >> testServicesDoIfNone [
| component exception |
"First: with found services"
component := MolUtils startComponent: MolCompleteComponentImpl.
component getMolUsedServicesProvider servicesDo: [ :s |
self assert: s isFoundServices.
self assert: s service equals: #service.
] ifNone: [ self fail ].
"Second: with not found services"
component := MolCompleteComponentImpl new.
component getMolUsedServicesProvider servicesDo: [ :s | self fail ] ifNone: [
exception := true.
].
self assert: exception.
]
{ #category : #tests }
MolComponentImplTest >> testServicesProviders [
| component |
component := MolCompleteComponentImpl new.
self assert: component servicesProviders isEmpty.
component := MolUtils deployAndInitializeComponent: MolCompleteComponentImpl named: #myComponentA.
"Test initial events producer contents : default component name"
self assert: component servicesProviders size equals: 1.
self assert: (component servicesProviders at: MolUsedServices) equals: MolUtils defaultComponentName.
MolUtils activateComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component servicesProviders size equals: 1.
self assert: (component servicesProviders at: MolUsedServices) equals: MolUtils defaultComponentName.
MolUtils passivateComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component servicesProviders size equals: 1.
self assert: (component servicesProviders at: MolUsedServices) equals: MolUtils defaultComponentName.
MolUtils removeComponent: MolCompleteComponentImpl named: #myComponentA.
self assert: component servicesProviders isEmpty.
]
{ #category : #'tests - component creation' }
MolComponentImplTest >> testStart [
MolCompleteComponentImpl deploy.
MolCompleteComponentImpl instantiate.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl) notNil.
MolCompleteComponentImpl activate.
MolCompleteComponentImpl passivate.
MolCompleteComponentImpl remove.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl) isNil.
MolCompleteComponentImpl undeploy
]
{ #category : #'tests - component creation' }
MolComponentImplTest >> testStart2 [
| component |
component := MolCompleteComponentImpl start.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl) notNil.
self assert: component isComponent.
self assert: component componentName equals: MolUtils defaultComponentName.
component := MolCompleteComponentImpl start: #compA.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl named: #compA) notNil.
self assert: component isComponent.
self assert: component componentName equals: #compA.
]
{ #category : #'tests - component creation' }
MolComponentImplTest >> testStartWithGeneratedName [
| instance instance2 |
instance := MolCompleteComponentImpl startWithGeneratedName.
self assert: instance componentName notNil.
self assert: instance componentName isSymbol.
instance2 := MolCompleteComponentImpl startWithGeneratedName.
self assert: instance2 componentName notNil.
self assert: instance2 componentName isSymbol.
self deny: instance componentName equals: instance2 componentName.
]
{ #category : #'tests - component creation' }
MolComponentImplTest >> testStartWithName [
MolCompleteComponentImpl deploy.
MolCompleteComponentImpl instantiate: #myComponent.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl named: #myComponent) notNil.
MolCompleteComponentImpl activate: #myComponent.
MolCompleteComponentImpl passivate: #myComponent.
MolCompleteComponentImpl remove: #myComponent.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl named: #myComponent) isNil.
MolCompleteComponentImpl undeploy
]
{ #category : #'tests - component creation' }
MolComponentImplTest >> testStartWithWrongNames [
"Start component with different types of component name"
| component error |
[component := MolCompleteComponentImpl start: 'myComponentName'] on: Error do:[ :e |
error := e.
].
self assert: (error isKindOf: WrongComponentNameError).
self assert: component isNil.
error := nil.
[component := MolCompleteComponentImpl start: 12] on: Error do:[ :e |
error := e.
].
self assert: (error isKindOf: WrongComponentNameError).
self assert: component isNil.
error := nil.
[component := MolCompleteComponentImpl start: (OrderedCollection new)] on: Error do:[ :e |
error := e.
].
self assert: (error isKindOf: WrongComponentNameError).
self assert: component isNil.
error := nil.
[component := MolCompleteComponentImpl start: nil] on: Error do:[ :e |
error := e.
].
self assert: (error isKindOf: WrongComponentNameError).
self assert: component isNil.
]
{ #category : #'tests - component creation' }
MolComponentImplTest >> testStop [
MolCompleteComponentImpl start.
MolCompleteComponentImpl stop.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl) equals: nil.
MolCompleteComponentImpl start: #compA.
MolCompleteComponentImpl stop: #compA.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl named: #compA) equals: nil.
]
{ #category : #'tests - component creation' }
MolComponentImplTest >> testStopInstance [
| instance |
instance := MolCompleteComponentImpl start.
instance stop.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl) equals: nil.
instance := MolCompleteComponentImpl start: #test.
instance stop.
self assert: (MolUtils instanceOf: MolCompleteComponentImpl) equals: nil.
]