diff --git a/.travis.yml b/.travis.yml index 105ebbe..91a402b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,4 @@ os: - linux smalltalk: - Pharo64-7.0 -- Pharo32-7.0 -- Pharo32-6.1 +- Pharo32-7.0 \ No newline at end of file diff --git a/source/OKR-Model/IdentifiableObject.trait.st b/source/OKR-Model/IdentifiableObject.trait.st new file mode 100644 index 0000000..3d9f83d --- /dev/null +++ b/source/OKR-Model/IdentifiableObject.trait.st @@ -0,0 +1,14 @@ +Trait { + #name : #IdentifiableObject, + #instVars : [ + 'uuid' + ], + #category : #'OKR-Model-API' +} + +{ #category : #accessing } +IdentifiableObject >> uuid [ + + uuid ifNil: [ uuid := UUID new ]. + ^ uuid +] diff --git a/source/OKR-Model/KeyResult.class.st b/source/OKR-Model/KeyResult.class.st index 144810d..8e43c74 100644 --- a/source/OKR-Model/KeyResult.class.st +++ b/source/OKR-Model/KeyResult.class.st @@ -1,6 +1,8 @@ Class { #name : #KeyResult, #superclass : #Object, + #traits : 'IdentifiableObject', + #classTraits : 'IdentifiableObject classTrait', #instVars : [ 'description', 'weight' diff --git a/source/OKR-Model/KeyResultManagementSystem.class.st b/source/OKR-Model/KeyResultManagementSystem.class.st index 9cb6d51..51bc092 100644 --- a/source/OKR-Model/KeyResultManagementSystem.class.st +++ b/source/OKR-Model/KeyResultManagementSystem.class.st @@ -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 @@ -45,3 +51,9 @@ KeyResultManagementSystem >> startManagingKeyResult: aKeyResult [ keyResults add: aKeyResult ] + +{ #category : #querying } +KeyResultManagementSystem >> stopManagingKeyResult: aKeyResult [ + + keyResults remove: aKeyResult +] diff --git a/source/OKR-Model/ManifestOKRModel.class.st b/source/OKR-Model/ManifestOKRModel.class.st index a5bc651..adaf1b4 100644 --- a/source/OKR-Model/ManifestOKRModel.class.st +++ b/source/OKR-Model/ManifestOKRModel.class.st @@ -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:) ] diff --git a/source/OKR-Model/Objective.class.st b/source/OKR-Model/Objective.class.st new file mode 100644 index 0000000..a92e5e6 --- /dev/null +++ b/source/OKR-Model/Objective.class.st @@ -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 +] diff --git a/source/OKR-Model/ObjectiveManagementSystem.class.st b/source/OKR-Model/ObjectiveManagementSystem.class.st new file mode 100644 index 0000000..2679648 --- /dev/null +++ b/source/OKR-Model/ObjectiveManagementSystem.class.st @@ -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 +] diff --git a/source/OKR-Model/Period.class.st b/source/OKR-Model/Period.class.st index acb60e7..eb37f3e 100644 --- a/source/OKR-Model/Period.class.st +++ b/source/OKR-Model/Period.class.st @@ -1,11 +1,12 @@ Class { #name : #Period, #superclass : #Object, + #traits : 'IdentifiableObject', + #classTraits : 'IdentifiableObject classTrait', #instVars : [ 'name', 'startDate', - 'endDate', - 'uuid' + 'endDate' ], #category : #'OKR-Model-Core' } @@ -26,8 +27,7 @@ Period >> endDate [ { #category : #initialization } Period >> initializeNamed: aName from: aStartDate to: anEndDate [ - - uuid := UUID new. + name := aName. startDate := aStartDate. endDate := anEndDate @@ -51,9 +51,3 @@ Period >> synchronizeWith: aPeriod [ startDate := aPeriod startDate. endDate := aPeriod endDate ] - -{ #category : #accessing } -Period >> uuid [ - - ^ uuid -] diff --git a/source/OKR-Model/PeriodManagementSystem.class.st b/source/OKR-Model/PeriodManagementSystem.class.st index ac49d2c..cc689eb 100644 --- a/source/OKR-Model/PeriodManagementSystem.class.st +++ b/source/OKR-Model/PeriodManagementSystem.class.st @@ -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 diff --git a/source/OKR-Tests/KeyResultManagementSystemUserStoryTest.class.st b/source/OKR-Tests/KeyResultManagementSystemUserStoryTest.class.st index 0760712..82b8b63 100644 --- a/source/OKR-Tests/KeyResultManagementSystemUserStoryTest.class.st +++ b/source/OKR-Tests/KeyResultManagementSystemUserStoryTest.class.st @@ -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 [ @@ -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 +] diff --git a/source/OKR-Tests/KeyResultTest.class.st b/source/OKR-Tests/KeyResultTest.class.st index fd19ade..14fc739 100644 --- a/source/OKR-Tests/KeyResultTest.class.st +++ b/source/OKR-Tests/KeyResultTest.class.st @@ -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 [ diff --git a/source/OKR-Tests/ObjectiveManagementSystemUserStoryTest.class.st b/source/OKR-Tests/ObjectiveManagementSystemUserStoryTest.class.st new file mode 100644 index 0000000..9ab0080 --- /dev/null +++ b/source/OKR-Tests/ObjectiveManagementSystemUserStoryTest.class.st @@ -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 +] diff --git a/source/OKR-Tests/ObjectiveTest.class.st b/source/OKR-Tests/ObjectiveTest.class.st new file mode 100644 index 0000000..3558917 --- /dev/null +++ b/source/OKR-Tests/ObjectiveTest.class.st @@ -0,0 +1,32 @@ +" +An ObjectiveTest is a test class for testing the behavior of Objective +" +Class { + #name : #ObjectiveTest, + #superclass : #TestCase, + #category : #'OKR-Tests-Core' +} + +{ #category : #tests } +ObjectiveTest >> testCreation [ + + | objective keyResults | + + keyResults := {( KeyResult describedBy: 'Implementar modelo de Key Result' weighted: 30 percent ). + ( KeyResult describedBy: 'Implementar sistema de Key Result' weighted: 30 percent ). + ( KeyResult describedBy: 'Implementar API de Key Result' weighted: 40 percent )}. + objective := Objective describedBy: 'Implementar Key Results' withKeyResults: keyResults. + self + assert: objective description equals: 'Implementar Key Results'; + assertCollection: objective keyResults equals: keyResults +] + +{ #category : #tests } +ObjectiveTest >> testUUIDTrait [ + + | objective | + + objective := Objective describedBy: 'Implementar Key Results' withKeyResults: #(). + + self assert: ( objective uuid isA: UUID ) +] diff --git a/source/OKR-Tests/PeriodTest.class.st b/source/OKR-Tests/PeriodTest.class.st index 55e1351..dbb33d7 100644 --- a/source/OKR-Tests/PeriodTest.class.st +++ b/source/OKR-Tests/PeriodTest.class.st @@ -29,3 +29,12 @@ PeriodTest >> testPeriodSynchronization [ self assert: period startDate equals: January first , 2020. self assert: period endDate equals: ( March , 2020 ) lastDate ] + +{ #category : #Testing } +PeriodTest >> testUUIDTrait [ + + | period | + + period := Period named: '2019Q1' from: January first , 2019 to: ( March , 2019 ) lastDate. + self assert: ( period uuid isA: UUID ) +]