Skip to content

Commit

Permalink
Merge pull request #34 from ba-st/33-Add-time-and-event-notification-…
Browse files Browse the repository at this point in the history
…modules

Added time and event notification modules
  • Loading branch information
fortizpenaloza authored Apr 11, 2019
2 parents c597f02 + 792e235 commit fe80525
Show file tree
Hide file tree
Showing 19 changed files with 242 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"
An EventNotificationModuleTest is a test class for testing the behavior of EventNotificationModule
"
Class {
#name : #EventNotificationModuleTest,
#superclass : #SystemBasedUserStoryTest,
#category : #'Kepler-Notifications-Tests'
}

{ #category : #'private - accessing' }
EventNotificationModuleTest >> installedModuleRegistrationSystem [

^ rootSystem >> #InstalledModuleRegistrationSystem
]

{ #category : #'private - configuring' }
EventNotificationModuleTest >> requireEventNotificationModule [

self requireInstallationOf: EventNotificationModule
]

{ #category : #'private - running' }
EventNotificationModuleTest >> setUpRequirements [

self requireEventNotificationModule
]

{ #category : #tests }
EventNotificationModuleTest >> testAccessing [

| eventNotificationModule |

eventNotificationModule := self installedModuleRegistrationSystem
installedModuleRegisteringSystemImplementing: #EventNotificationSystemInterface.

self
assert: eventNotificationModule name equals: 'Event notification';
assert: eventNotificationModule systemInterfacesToInstall
equals: #(#EventNotificationSystemInterface)
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
#category : 'Kepler-Notifications-Tests'
}

{ #category : #tests }
{ #category : #accessing }
EventNotificationSystemUserStoryTest >> eventNotificationSystem [

^ rootSystem >> #EventNotificationSystemInterface
Expand Down
47 changes: 47 additions & 0 deletions source/Kepler-Notifications/EventNotificationModule.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"
I'm system module installing the event notification system
"
Class {
#name : #EventNotificationModule,
#superclass : #SystemModule,
#instVars : [
'rootSystem'
],
#category : #'Kepler-Notifications'
}

{ #category : #'instance creation' }
EventNotificationModule class >> toInstallOn: aCompositeSystem [

^ self new initializeToInstallOn: aCompositeSystem
]

{ #category : #initialization }
EventNotificationModule >> initializeToInstallOn: aCompositeSystem [

rootSystem := aCompositeSystem
]

{ #category : #private }
EventNotificationModule >> name [

^ 'Event notification'
]

{ #category : #private }
EventNotificationModule >> registerEventNotificationSystemForInstallationIn: systems [

^ self register: [ EventNotificationSystem new ] in: systems
]

{ #category : #private }
EventNotificationModule >> rootSystem [

^ rootSystem
]

{ #category : #private }
EventNotificationModule >> systemInterfacesToInstall [

^ #(#EventNotificationSystemInterface)
]
5 changes: 5 additions & 0 deletions source/Kepler-Notifications/EventNotificationSystem.class.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"
I'm SubsystemImplementation.
I'm an event notification system and I manage subscriptions allowing to create or revoke them. Also, I receive events and notify their subscribers.
"
Class {
#name : #EventNotificationSystem,
#superclass : #SubsystemImplementation,
Expand Down
7 changes: 6 additions & 1 deletion source/Kepler-Notifications/NotifiableEvent.class.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"
I'm a notifiable event.
The event notification system notifies subscribers that you have received me.
"
Class {
#name : #NotifiableEvent,
#superclass : #Object,
#category : 'Kepler-Notifications'
#category : #'Kepler-Notifications'
}
7 changes: 6 additions & 1 deletion source/Kepler-Notifications/Subscription.class.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"
I'm a Subscription.
I know what message to send to a subscriber each time the event notification system receives an event.
"
Class {
#name : #Subscription,
#superclass : #Object,
Expand All @@ -6,7 +11,7 @@ Class {
'subscriber',
'message'
],
#category : 'Kepler-Notifications'
#category : #'Kepler-Notifications'
}

{ #category : #'instance creation' }
Expand Down
20 changes: 18 additions & 2 deletions source/Kepler-SUnit-Model/SystemBasedUserStoryTest.class.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"
I'm a TestCase extension supporting System level tests.
I'm a TestCase extension supporting system level tests.
My subclasses need to implement setUpRequirements and install here the required modules or subsystems needed for the specific case.
"
Class {
Expand All @@ -17,12 +18,27 @@ SystemBasedUserStoryTest class >> isAbstract [
^self name = #SystemBasedUserStoryTest
]

{ #category : #'private - running' }
{ #category : #'private - configuring' }
SystemBasedUserStoryTest >> registerInstalledModuleRegistrationSystem [

rootSystem
systemImplementing: #InstalledModuleRegistrationSystem
ifNone: [ self registerSubsystem: InstalledModuleRegistrationSystem new ]
]

{ #category : #'private - configuring' }
SystemBasedUserStoryTest >> registerSubsystem: aSubsystem [

rootSystem register: aSubsystem
]

{ #category : #'private - configuring' }
SystemBasedUserStoryTest >> requireInstallationOf: aModuleFactory [

self registerInstalledModuleRegistrationSystem.
(aModuleFactory toInstallOn: rootSystem) install
]

{ #category : #running }
SystemBasedUserStoryTest >> setUp [

Expand Down
2 changes: 1 addition & 1 deletion source/Kepler-System-Tests/SampleCustomerModule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
{ #category : #'instance creation' }
SampleCustomerModule class >> toInstallOn: aCompositeSystem [

^self new initializeToInstallOn: aCompositeSystem
^ self new initializeToInstallOn: aCompositeSystem
]

{ #category : #initialization }
Expand Down
8 changes: 7 additions & 1 deletion source/Kepler-System-Tests/SampleProjectModule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
{ #category : #'instance creation' }
SampleProjectModule class >> toInstallOn: aCompositeSystem [

^self new initializeToInstallOn: aCompositeSystem
^ self new initializeToInstallOn: aCompositeSystem
]

{ #category : #initialization }
Expand All @@ -22,6 +22,12 @@ SampleProjectModule >> initializeToInstallOn: aCompositeSystem [
rootSystem := aCompositeSystem
]

{ #category : #private }
SampleProjectModule >> name [

^ 'Project'
]

{ #category : #private }
SampleProjectModule >> registerProjectManagementSystemForInstallationIn: systems [

Expand Down
3 changes: 3 additions & 0 deletions source/Kepler-System/SystemCommandExecutionError.class.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"
I'm an error raised when something goes wrong during a collaboration with a system
"
Class {
#name : #SystemCommandExecutionError,
#superclass : #Error,
Expand Down
2 changes: 1 addition & 1 deletion source/Kepler-System/SystemInstallation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SystemInstallation >> install: aVersionName [
rootSystem := CompositeSystem installedBy: self.
self registerModuleRegistrationSystemOn: rootSystem.
self modulesToInstall do: [ :module | (module toInstallOn: rootSystem) install ].
^rootSystem
^ rootSystem
]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion source/Kepler-System/SystemModule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SystemModule >> printOn: aStream [
{ #category : #private }
SystemModule >> register: aSystemCreationBlock in: systems [

^systems add: aSystemCreationBlock value
^ systems add: aSystemCreationBlock value
]

{ #category : #actions }
Expand Down
40 changes: 40 additions & 0 deletions source/Kepler-Time-Tests/TimeModuleTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"
A TimeModuleTest is a test class for testing the behavior of TimeModule
"
Class {
#name : #TimeModuleTest,
#superclass : #SystemBasedUserStoryTest,
#category : #'Kepler-Time-Tests'
}

{ #category : #'private - accessing' }
TimeModuleTest >> installedModuleRegistrationSystem [

^ rootSystem >> #InstalledModuleRegistrationSystem
]

{ #category : #'private - configuring' }
TimeModuleTest >> requireTimeModule [

self requireInstallationOf: TimeModule
]

{ #category : #'private - running' }
TimeModuleTest >> setUpRequirements [

self requireTimeModule
]

{ #category : #tests }
TimeModuleTest >> testAccessing [

| eventNotificationModule |

eventNotificationModule := self installedModuleRegistrationSystem
installedModuleRegisteringSystemImplementing: #TimeSystemInterface.

self
assert: eventNotificationModule name equals: 'Time';
assert: eventNotificationModule systemInterfacesToInstall
equals: #(#TimeSystemInterface)
]
3 changes: 1 addition & 2 deletions source/Kepler-Time/FixedTimeSource.class.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"
I'm FixedTimeSource.
I'm a TimeSource.
I provide a fixed previously given date and time. I exist only for testing purposes.
Expand All @@ -11,7 +10,7 @@ Class {
#instVars : [
'dateTime'
],
#category : 'Kepler-Time'
#category : #'Kepler-Time'
}

{ #category : #'instance creation' }
Expand Down
2 changes: 1 addition & 1 deletion source/Kepler-Time/ManifestKeplerTime.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ I store metadata for this package. These meta data are used by other tools such
Class {
#name : #ManifestKeplerTime,
#superclass : #PackageManifest,
#category : #'Kepler-Time'
#category : #'Kepler-Time-Manifest'
}

{ #category : #'class initialization' }
Expand Down
8 changes: 7 additions & 1 deletion source/Kepler-Time/SystemTimeSource.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"
I'm a TimeSource.
I provide the system's current date and time.
"
Class {
#name : #SystemTimeSource,
#superclass : #TimeSource,
#category : 'Kepler-Time'
#category : #'Kepler-Time'
}

{ #category : #accessing }
Expand Down
49 changes: 49 additions & 0 deletions source/Kepler-Time/TimeModule.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"
I'm SytemModule.
I'm a system module installing the time system.
"
Class {
#name : #TimeModule,
#superclass : #SystemModule,
#instVars : [
'rootSystem'
],
#category : #'Kepler-Time'
}

{ #category : #'instance creation' }
TimeModule class >> toInstallOn: aCompositeSystem [

^ self new initializeToInstallOn: aCompositeSystem
]

{ #category : #initialization }
TimeModule >> initializeToInstallOn: aCompositeSystem [

rootSystem := aCompositeSystem
]

{ #category : #private }
TimeModule >> name [

^ 'Time'
]

{ #category : #private }
TimeModule >> registerTimeSystemForInstallationIn: systems [

^ self register: [ TimeSystem using: SystemTimeSource new ] in: systems
]

{ #category : #private }
TimeModule >> rootSystem [

^ rootSystem
]

{ #category : #private }
TimeModule >> systemInterfacesToInstall [

^ #(#TimeSystemInterface)
]
7 changes: 6 additions & 1 deletion source/Kepler-Time/TimeSource.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
"
I'm a TimeSource.
I provide a date and time.
"
Class {
#name : #TimeSource,
#superclass : #Object,
#category : 'Kepler-Time'
#category : #'Kepler-Time'
}

{ #category : #accessing }
Expand Down
9 changes: 2 additions & 7 deletions source/Kepler-Time/TimeSystem.class.st
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
"
A TimeSystem is a system that provides time.
Instance Variables
timeSource: <Object>
timeSource
- xxxxx
I'm a SubsystemImplementation.
I'm a system that provides the date, the time of day or both.
"
Class {
#name : #TimeSystem,
Expand Down

0 comments on commit fe80525

Please sign in to comment.