Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objective model and System #18

Merged
merged 2 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ os:
- linux
smalltalk:
- Pharo64-7.0
- Pharo32-7.0
- Pharo32-6.1
- Pharo32-7.0
14 changes: 14 additions & 0 deletions source/OKR-Model/IdentifiableObject.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Trait {
#name : #IdentifiableObject,
#instVars : [
'uuid'
],
#category : #'OKR-Model-API'
}

{ #category : #accessing }
IdentifiableObject >> uuid [

uuid ifNil: [ uuid := UUID new ].
^ uuid
]
2 changes: 2 additions & 0 deletions source/OKR-Model/KeyResult.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Class {
#name : #KeyResult,
#superclass : #Object,
#traits : 'IdentifiableObject',
#classTraits : 'IdentifiableObject classTrait',
#instVars : [
'description',
'weight'
Expand Down
14 changes: 13 additions & 1 deletion source/OKR-Model/KeyResultManagementSystem.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ KeyResultManagementSystem >> initialize [

]

{ #category : #accessing }
{ #category : #querying }
KeyResultManagementSystem >> keyResultIdentifiedBy: anUUID ifFound: aBlock ifNone: aNoneBlock [

^ keyResults detect: [ :keyResult | keyResult uuid = anUUID ] ifFound: aBlock ifNone: aNoneBlock
]

{ #category : #querying }
KeyResultManagementSystem >> keyResults [

^ keyResults
Expand All @@ -45,3 +51,9 @@ KeyResultManagementSystem >> startManagingKeyResult: aKeyResult [

keyResults add: aKeyResult
]

{ #category : #querying }
KeyResultManagementSystem >> stopManagingKeyResult: aKeyResult [

keyResults remove: aKeyResult
]
9 changes: 7 additions & 2 deletions source/OKR-Model/ManifestOKRModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ ManifestOKRModel class >> initialize [
Kepler
registerInterfaceAt: #PeriodManagementSystem
named: 'System to manage periods'
declaring: #(#periods #startManagingPeriod:);
declaring: #(#periodIdentifiedBy:ifFound:ifNone: #periods #startManagingPeriod: #stopManagingPeriod:);
registerInterfaceAt: #KeyResultManagementSystem
named: 'System to manage key results'
declaring: #(#keyResults #startManagingKeyResult:)
declaring:
#(#keyResultIdentifiedBy:ifFound:ifNone: #keyResults #startManagingKeyResult: #stopManagingKeyResult:);
registerInterfaceAt: #ObjectiveManagementSystem
named: 'System to manage objectives'
declaring:
#(#objectiveIdentifiedBy:ifFound:ifNone: #objectives #startManagingObjectives: #stopManagingObjectives:)
]
36 changes: 36 additions & 0 deletions source/OKR-Model/Objective.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Class {
#name : #Objective,
#superclass : #Object,
#traits : 'IdentifiableObject',
#classTraits : 'IdentifiableObject classTrait',
#instVars : [
'description',
'keyResults'
],
#category : #'OKR-Model-Core'
}

{ #category : #'Instance creation' }
Objective class >> describedBy: aDescription withKeyResults: aCollection [

^ self new initializeDescribedBy: aDescription withKeyResults: aCollection
]

{ #category : #accessing }
Objective >> description [

^ description
]

{ #category : #initialization }
Objective >> initializeDescribedBy: aDescription withKeyResults: aCollection [

description := aDescription.
keyResults := aCollection
]

{ #category : #accessing }
Objective >> keyResults [

^ keyResults
]
59 changes: 59 additions & 0 deletions source/OKR-Model/ObjectiveManagementSystem.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Class {
#name : #ObjectiveManagementSystem,
#superclass : #SubsystemImplementation,
#instVars : [
'objectives'
],
#category : #'OKR-Model-Core'
}

{ #category : #installing }
ObjectiveManagementSystem >> dependencies [

^ #()
]

{ #category : #installing }
ObjectiveManagementSystem >> implementedInterfaces [

^ #(#ObjectiveManagementSystem)
]

{ #category : #initialization }
ObjectiveManagementSystem >> initialize [

super initialize.

objectives := OrderedCollection new.

]

{ #category : #accessing }
ObjectiveManagementSystem >> name [

^ 'System to manage objectives'
]

{ #category : #querying }
ObjectiveManagementSystem >> objectiveIdentifiedBy: anUUID ifFound: aBlock ifNone: aNoneBlock [

^ objectives detect: [ :objective | objective uuid = anUUID ] ifFound: aBlock ifNone: aNoneBlock
]

{ #category : #querying }
ObjectiveManagementSystem >> objectives [

^ objectives
]

{ #category : #managing }
ObjectiveManagementSystem >> startManagingObjective: anObjective [

objectives add: anObjective
]

{ #category : #'managing container' }
ObjectiveManagementSystem >> stopManagingObjective: anObjective [

objectives remove: anObjective
]
14 changes: 4 additions & 10 deletions source/OKR-Model/Period.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Class {
#name : #Period,
#superclass : #Object,
#traits : 'IdentifiableObject',
#classTraits : 'IdentifiableObject classTrait',
#instVars : [
'name',
'startDate',
'endDate',
'uuid'
'endDate'
],
#category : #'OKR-Model-Core'
}
Expand All @@ -26,8 +27,7 @@ Period >> endDate [

{ #category : #initialization }
Period >> initializeNamed: aName from: aStartDate to: anEndDate [

uuid := UUID new.

name := aName.
startDate := aStartDate.
endDate := anEndDate
Expand All @@ -51,9 +51,3 @@ Period >> synchronizeWith: aPeriod [
startDate := aPeriod startDate.
endDate := aPeriod endDate
]

{ #category : #accessing }
Period >> uuid [

^ uuid
]
2 changes: 1 addition & 1 deletion source/OKR-Model/PeriodManagementSystem.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PeriodManagementSystem >> periodIdentifiedBy: anUUID ifFound: aBlock ifNone: aNo
^ periods detect: [ :period | period uuid = anUUID ] ifFound: aBlock ifNone: aNoneBlock
]

{ #category : #accessing }
{ #category : #querying }
PeriodManagementSystem >> periods [

^ periods
Expand Down
49 changes: 49 additions & 0 deletions source/OKR-Tests/KeyResultManagementSystemUserStoryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ KeyResultManagementSystemUserStoryTest >> testEmptySystem [
self assert: self keyResultManagementSystem keyResults isEmpty
]

{ #category : #'private - running' }
KeyResultManagementSystemUserStoryTest >> testKeyResultIdentifiedBy [

| q1 q2 found |

q1 := KeyResult describedBy: 'do something' weighted: 20 percent.
q2 := KeyResult describedBy: 'do some otherthing' weighted: 30 percent.
self keyResultManagementSystem
startManagingKeyResult: q1;
startManagingKeyResult: q2.

found := false.
self keyResultManagementSystem
keyResultIdentifiedBy: q1 uuid
ifFound: [ :keyResult |
self assert: keyResult equals: q1.
found := true
]
ifNone: [ self fail ].
self assert: found.

found := false.
self keyResultManagementSystem
keyResultIdentifiedBy: q2 uuid
ifFound: [ :keyResult |
self assert: keyResult equals: q2.
found := true
]
ifNone: [ self fail ].
self assert: found
]

{ #category : #'private - running' }
KeyResultManagementSystemUserStoryTest >> testStartManagingKeyResult [

Expand All @@ -35,3 +67,20 @@ KeyResultManagementSystemUserStoryTest >> testStartManagingKeyResult [
withTheOnlyOneIn: self keyResultManagementSystem keyResults
do: [ :foundKeyResult | self assert: keyResult equals: foundKeyResult ]
]

{ #category : #'private - running' }
KeyResultManagementSystemUserStoryTest >> testStopManagingKeyResult [

| keyResult |

keyResult := KeyResult describedBy: 'Implementar modelo de Key Result' weighted: 20 percent.

self keyResultManagementSystem startManagingKeyResult: keyResult.

self
withTheOnlyOneIn: self keyResultManagementSystem keyResults
do: [ :foundKeyResult | self assert: keyResult equals: foundKeyResult ].

self keyResultManagementSystem stopManagingKeyResult: keyResult.
self assert: self keyResultManagementSystem keyResults isEmpty
]
10 changes: 10 additions & 0 deletions source/OKR-Tests/KeyResultTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ KeyResultTest >> testCreation [
assert: kr weight equals: 20 percent
]

{ #category : #tests }
KeyResultTest >> testUUIDTrait [

| kr |

kr := KeyResult describedBy: 'Implementar modelo de Key Result' weighted: 20 percent.

self assert: ( kr uuid isA: UUID )
]

{ #category : #tests }
KeyResultTest >> testWeightMustBeAValidCompositionPercentage [

Expand Down
86 changes: 86 additions & 0 deletions source/OKR-Tests/ObjectiveManagementSystemUserStoryTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Class {
#name : #ObjectiveManagementSystemUserStoryTest,
#superclass : #SystemBasedUserStoryTest,
#category : #'OKR-Tests-Core'
}

{ #category : #accessing }
ObjectiveManagementSystemUserStoryTest >> objectiveManagementSystem [

^ rootSystem >> #ObjectiveManagementSystem
]

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

self registerSubsystem: ObjectiveManagementSystem new
]

{ #category : #'private - running' }
ObjectiveManagementSystemUserStoryTest >> testEmptySystem [

self assert: self objectiveManagementSystem objectives isEmpty
]

{ #category : #'private - running' }
ObjectiveManagementSystemUserStoryTest >> testObjectiveIdentifiedBy [

| q1 q2 found |

q1 := Objective describedBy: 'An Objective' withKeyResults: #().
q2 := Objective describedBy: 'Another Objective' withKeyResults: #().
self objectiveManagementSystem
startManagingObjective: q1;
startManagingObjective: q2.

found := false.
self objectiveManagementSystem
objectiveIdentifiedBy: q1 uuid
ifFound: [ :objective |
self assert: objective equals: q1.
found := true
]
ifNone: [ self fail ].
self assert: found.

found := false.
self objectiveManagementSystem
objectiveIdentifiedBy: q2 uuid
ifFound: [ :objective |
self assert: objective equals: q2.
found := true
]
ifNone: [ self fail ].
self assert: found
]

{ #category : #'private - running' }
ObjectiveManagementSystemUserStoryTest >> testStartManagingObjective [

| objective |

objective := Objective describedBy: 'An Objective' withKeyResults: #().

self objectiveManagementSystem startManagingObjective: objective.

self
withTheOnlyOneIn: self objectiveManagementSystem objectives
do: [ :foundObjective | self assert: objective equals: foundObjective ]
]

{ #category : #'private - running' }
ObjectiveManagementSystemUserStoryTest >> testStopManagingObjective [

| objective |

objective := Objective describedBy: 'An Objective' withKeyResults: #().

self objectiveManagementSystem startManagingObjective: objective.

self
withTheOnlyOneIn: self objectiveManagementSystem objectives
do: [ :foundObjective | self assert: objective equals: foundObjective ].

self objectiveManagementSystem stopManagingObjective: objective.
self assert: self objectiveManagementSystem objectives isEmpty
]
Loading