Skip to content

Commit

Permalink
Merge pull request #187 from OpenSmock/dev_impl_defineContract
Browse files Browse the repository at this point in the history
Dev impl define contract
  • Loading branch information
labordep authored Sep 30, 2024
2 parents 851079d + 73cc3dd commit 4557c77
Show file tree
Hide file tree
Showing 8 changed files with 635 additions and 172 deletions.
151 changes: 151 additions & 0 deletions src/Molecule-Tests/MolCompleteComponentOverloadImpl.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
"
I am a component impl overloading my contract for impl purpose
"
Class {
#name : #MolCompleteComponentOverloadImpl,
#superclass : #MolAbstractComponentImpl,
#traits : 'MolCompleteComponent + MolUsedServices + MolUsedEvents + MolUsedParameters + MolUsedParameters2 + MolUsedServices2 + MolUsedEvents2',
#classTraits : 'MolCompleteComponent classTrait + MolUsedServices classTrait + MolUsedEvents classTrait + MolUsedParameters classTrait + MolUsedParameters2 classTrait + MolUsedServices2 classTrait + MolUsedEvents2 classTrait',
#category : #'Molecule-Tests-Resources - Components'
}

{ #category : #'accessing - events' }
MolCompleteComponentOverloadImpl class >> consumedComponentEvents [

<componentContract>
^ { MolUsedEvents. MolUsedEvents2 }
]

{ #category : #'accessing - events' }
MolCompleteComponentOverloadImpl class >> producedComponentEvents [

<componentContract>
^ {
MolUsedEvents.
MolUsedEvents2 }
]

{ #category : #'accessing - parameters' }
MolCompleteComponentOverloadImpl class >> providedComponentParameters [

<componentContract>
^ { MolUsedParameters. MolUsedParameters2. }
]

{ #category : #'accessing - services' }
MolCompleteComponentOverloadImpl class >> providedComponentServices [

<componentContract>
^ { MolUsedServices. MolUsedServices2 }
]

{ #category : #'accessing - parameters' }
MolCompleteComponentOverloadImpl class >> usedComponentParameters [

<componentContract>
^ { MolUsedParameters. MolUsedParameters2 }
]

{ #category : #'accessing - services' }
MolCompleteComponentOverloadImpl class >> usedComponentServices [

<componentContract>
^ { MolUsedServices. MolUsedServices2 }
]

{ #category : #events }
MolCompleteComponentOverloadImpl >> event [
^ #event
]

{ #category : #'component accessing' }
MolCompleteComponentOverloadImpl >> getMolUsedEvents2Notifier [
^self eventsNotifiers at: MolUsedEvents2 ifAbsent: [^MolNotFoundEventsNotifier new interface: MolUsedEvents2 name: nil].
]

{ #category : #'component accessing' }
MolCompleteComponentOverloadImpl >> getMolUsedEvents2Subscriber [
| eventsSymbol eventsSubscriber itf |
itf := MolUsedEvents2.
eventsSymbol := self eventsSubscribers at: itf ifAbsent: [^MolNotFoundEventsSubscriber new interface: itf name: nil].
eventsSymbol isCollection
ifTrue:
[eventsSubscriber := MolComponentManager default locatorServices
searchEventsSubscriberFor: MolUsedEvents2 named: eventsSymbol ].
^eventsSubscriber
]

{ #category : #'component accessing' }
MolCompleteComponentOverloadImpl >> getMolUsedEventsNotifier [
^self eventsNotifiers at: MolUsedEvents ifAbsent: [^MolNotFoundEventsNotifier new interface: MolUsedEvents name: nil].
]

{ #category : #'component accessing' }
MolCompleteComponentOverloadImpl >> getMolUsedEventsSubscriber [
| eventsSymbol eventsSubscriber itf |
itf := MolUsedEvents.
eventsSymbol := self eventsSubscribers at: itf ifAbsent: [^MolNotFoundEventsSubscriber new interface: itf name: nil].
eventsSymbol isCollection
ifTrue:
[eventsSubscriber := MolComponentManager default locatorServices
searchEventsSubscriberFor: MolUsedEvents named: eventsSymbol ].
^eventsSubscriber
]

{ #category : #'component accessing' }
MolCompleteComponentOverloadImpl >> getMolUsedParameters2Provider [
| parametersSymbol parametersProvider itf |

itf := MolUsedParameters2.
parametersSymbol := self parametersProviders at: itf ifAbsent: [nil].
(parametersSymbol isNil or:[parametersSymbol isSymbol not]) ifTrue: [ ^ MolNotFoundParametersProvider new interface: itf name: nil ].

parametersProvider := MolComponentManager default locatorServices searchParametersProviderFor: MolUsedParameters2 named: parametersSymbol.
^parametersProvider
]

{ #category : #'component accessing' }
MolCompleteComponentOverloadImpl >> getMolUsedParametersProvider [
| parametersSymbol parametersProvider itf |

itf := MolUsedParameters.
parametersSymbol := self parametersProviders at: itf ifAbsent: [nil].
(parametersSymbol isNil or:[parametersSymbol isSymbol not]) ifTrue: [ ^ MolNotFoundParametersProvider new interface: itf name: nil ].

parametersProvider := MolComponentManager default locatorServices searchParametersProviderFor: MolUsedParameters named: parametersSymbol.
^parametersProvider
]

{ #category : #'component accessing' }
MolCompleteComponentOverloadImpl >> getMolUsedServices2Provider [
| servicesSymbol servicesProvider itf |

itf := MolUsedServices2.
servicesSymbol := self servicesProviders at: itf ifAbsent: [nil].
(servicesSymbol isNil or:[servicesSymbol isSymbol not]) ifTrue: [ ^ MolNotFoundServicesProvider new interface: itf name: nil ].

servicesProvider := MolComponentManager default locatorServices searchServicesProviderFor: MolUsedServices2 named: servicesSymbol.
^servicesProvider
]

{ #category : #'component accessing' }
MolCompleteComponentOverloadImpl >> getMolUsedServicesProvider [
| servicesSymbol servicesProvider itf |

itf := MolUsedServices.
servicesSymbol := self servicesProviders at: itf ifAbsent: [nil].
(servicesSymbol isNil or:[servicesSymbol isSymbol not]) ifTrue: [ ^ MolNotFoundServicesProvider new interface: itf name: nil ].

servicesProvider := MolComponentManager default locatorServices searchServicesProviderFor: MolUsedServices named: servicesSymbol.
^servicesProvider
]

{ #category : #parameters }
MolCompleteComponentOverloadImpl >> parameter [
^ #parameter
]

{ #category : #service }
MolCompleteComponentOverloadImpl >> service [
^ #service
]
15 changes: 15 additions & 0 deletions src/Molecule-Tests/MolComponentFactoryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,21 @@ MolComponentFactoryTest >> testComponentContractChanged [

]

{ #category : #tests }
MolComponentFactoryTest >> testComponentContractImplGeneration [

| toFind |
MolCompleteComponentOverloadImpl defineComponent.
toFind := { #getMolUsedEventsNotifier. #getMolUsedParametersProvider.
#getMolUsedServicesProvider. #getMolUsedEventsSubscriber.
#getMolUsedEventsSubscriber. #getMolUsedEvents2Notifier.
#getMolUsedParameters2Provider.
#getMolUsedServices2Provider }.
toFind := toFind reject: [ :e |
MolCompleteComponentOverloadImpl allSelectors includes: e ].
self assert: toFind isEmpty
]

{ #category : #tests }
MolComponentFactoryTest >> testComponentFactoryDefaultClass [
MolComponentFactory cleanUp.
Expand Down
15 changes: 15 additions & 0 deletions src/Molecule-Tests/MolUsedEvents2.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"
I am a event trait used for impl overloading test
"
Trait {
#name : #MolUsedEvents2,
#traits : 'MolComponentEvents',
#classTraits : 'MolComponentEvents classTrait',
#category : #'Molecule-Tests-Resources - Contracts'
}

{ #category : #events }
MolUsedEvents2 >> event2 [

^ #event2
]
15 changes: 15 additions & 0 deletions src/Molecule-Tests/MolUsedParameters2.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"
I am a param trait used for impl overloading test
"
Trait {
#name : #MolUsedParameters2,
#traits : 'MolComponentParameters',
#classTraits : 'MolComponentParameters classTrait',
#category : #'Molecule-Tests-Resources - Contracts'
}

{ #category : #'parameters 2' }
MolUsedParameters2 >> parameter2 [

^ #parameter2
]
15 changes: 15 additions & 0 deletions src/Molecule-Tests/MolUsedServices2.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"
I am a services trait used for impl overloading test
"
Trait {
#name : #MolUsedServices2,
#traits : 'MolComponentServices',
#classTraits : 'MolComponentServices classTrait',
#category : #'Molecule-Tests-Resources - Contracts'
}

{ #category : #'service 2' }
MolUsedServices2 >> service2 [

^ #service2
]
Loading

0 comments on commit 4557c77

Please sign in to comment.