Skip to content
Open
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
7 changes: 4 additions & 3 deletions source/BaselineOfTeamsApi/BaselineOfTeamsApi.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ BaselineOfTeamsApi >> baseline: spec [

{ #category : #accessing }
BaselineOfTeamsApi >> baselineTeamsApi: spec [

spec
package: 'TeamsAPI-Core' with: [ spec requires: #('Kepler') ];
group: 'Deployment' with: 'TeamsAPI-Core';
package: 'TeamsAPI-Core-Tests'
with: [ spec requires: 'Deployment' ];
group: 'Tests' with: 'TeamsAPI-Core-Tests'
with: [ spec requires: #('Deployment') ];
group: 'Deployment' with: #('TeamsAPI-Core');
group: 'Tests' with: #('TeamsAPI-Core-Tests')
]

{ #category : #accessing }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Class {
#name : #PeopleRESTfulControllerSpecificationTest,
#superclass : #TestCase,
#category : #'TeamsAPI-Core-Tests-Controllers'
}

{ #category : #'as yet unclassified' }
PeopleRESTfulControllerSpecificationTest >> testTemplate [

| spec |

spec := PeopleRESTfulControllerSpecification new.

self
assert: spec addTemplate equals: '/people/<identifier:IsInteger>';
assert: spec listTemplate equals: '/people';
assert: spec detailTemplate equals: '/people/<identifier:IsInteger>'
]
108 changes: 108 additions & 0 deletions source/TeamsAPI-Core-Tests/PeopleRESTfulControllerTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
Class {
#name : #PeopleRESTfulControllerTest,
#superclass : #ResourceRESTfulControllerTest,
#instVars : [
'peopleManagementSystem'
],
#category : #'TeamsAPI-Core-Tests-Controllers'
}

{ #category : #test }
PeopleRESTfulControllerTest >> baseUrl [

^ 'http://people.mercap.net' asZnUrl
]

{ #category : #'block support' }
PeopleRESTfulControllerTest >> defaultPersonMediaType [
^ resourceController specification personVersion1dot0dot0MediaType
]

{ #category : #'block support' }
PeopleRESTfulControllerTest >> registerPerson: aPerson [

peopleManagementSystem startManagingPerson: aPerson
]

{ #category : #'block support' }
PeopleRESTfulControllerTest >> requestToCreatePersonFrom: json [

^ self requestToPOST: json as: self defaultPersonMediaType
]

{ #category : #'block support' }
PeopleRESTfulControllerTest >> requestToGet: aUrl accepting: anAcceptHeader [

^ TeaRequest
fromZnRequest:
((ZnRequest get: aUrl)
setAccept: anAcceptHeader;
yourself)
]

{ #category : #'block support' }
PeopleRESTfulControllerTest >> requestToGetPeopleAccepting: anAcceptHeader [

^ self requestToGet: self resourceUrl accepting: anAcceptHeader
]

{ #category : #test }
PeopleRESTfulControllerTest >> setUp [

peopleManagementSystem := PeopleManagementSystem new.
super setUp
]

{ #category : #test }
PeopleRESTfulControllerTest >> setUpResourceController [

resourceController := PeopleRESTfulController
for: peopleManagementSystem
]

{ #category : #tests }
PeopleRESTfulControllerTest >> testGetWhenNoPeopleRegistered [

| response |

response := resourceController
getPeopleBasedOn: (self requestToGetPeopleAccepting: '*/*')
within: self newHttpRequestContext.

self
assert: response isSuccess;
assert: response status equals: 200;
assert: response contentType asMediaType
equals: resourceController specification personVersion1dot0dot0MediaType.

self
withJsonFromContentsIn: response
do: [ :people | self assert: people isEmpty ]
]

{ #category : #tests }
PeopleRESTfulControllerTest >> testPersonCreation [

| response |

response := resourceController
createPersonBasedOn:
(self
requestToCreatePersonFrom:
'{"name":"Roberto","lastName":"Rodriguez","email":"[email protected]"}')
within: self newHttpRequestContext.
self
assert: response isSuccess;
assert: response status equals: 201;
assertUrl: response location
equals: 'http://people.mercap.net/people/1';
assert: response hasEntity;
assert: peopleManagementSystem people size equals: 1;
assert: peopleManagementSystem people first name equals: 'Roberto'
]

{ #category : #test }
PeopleRESTfulControllerTest >> urlOf: aPerson [

^ (self resourceUrl / aPerson uuid asString) asString
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
A PersonSystemTest is a test class for testing the behavior of PersonSystem
"
Class {
#name : #PersonSystemTest,
#name : #PersonManagementSystemTest,
#superclass : #TestCase,
#instVars : [
'rootSystem'
],
#category : #'TeamsAPI-Core-Tests'
#category : #'TeamsAPI-Core-Tests-Systems'
}

{ #category : #acccessing }
PersonSystemTest >> lucasRojas [
PersonManagementSystemTest >> lucasRojas [
^ Person
named: 'Lucas'
surnamed: 'Rojas'
withEmailAddress: '[email protected]'
]

{ #category : #acccessing }
PersonSystemTest >> personSystem [
PersonManagementSystemTest >> personSystem [
^ rootSystem systemImplementing: #PersonSystemInterface
]

{ #category : #initializing }
PersonSystemTest >> setUp [
PersonManagementSystemTest >> setUp [
super setUp.
rootSystem := CompositeSystem new.
rootSystem
register: PersonSystem new;
register: TeamSystem new;
register: PeopleManagementSystem new;
register: TeamManagementSystem new;
startUp
]

{ #category : #tests }
PersonSystemTest >> testAddPerson [
PersonManagementSystemTest >> testAddPerson [
| person personSystem |
person := self lucasRojas.
personSystem := self personSystem.
Expand All @@ -45,7 +45,7 @@ PersonSystemTest >> testAddPerson [
]

{ #category : #tests }
PersonSystemTest >> testDeletePerson [
PersonManagementSystemTest >> testDeletePerson [
| person personSystem |
person := self lucasRojas.
personSystem := self personSystem.
Expand All @@ -58,7 +58,7 @@ PersonSystemTest >> testDeletePerson [
]

{ #category : #tests }
PersonSystemTest >> testFailToDeletePersonAlreadyDeleted [
PersonManagementSystemTest >> testFailToDeletePersonAlreadyDeleted [
| person personSystem |
person := self lucasRojas.
personSystem := self personSystem.
Expand All @@ -79,7 +79,7 @@ PersonSystemTest >> testFailToDeletePersonAlreadyDeleted [
]

{ #category : #tests }
PersonSystemTest >> testFailWhenAddingAPersonWithSameEmailAddress [
PersonManagementSystemTest >> testFailWhenAddingAPersonWithSameEmailAddress [
| person personSystem personWithSameEmail |
person := self lucasRojas.
personWithSameEmail := Person
Expand All @@ -101,6 +101,6 @@ PersonSystemTest >> testFailWhenAddingAPersonWithSameEmailAddress [
]

{ #category : #tests }
PersonSystemTest >> testGetPeopleOnEmptySystem [
PersonManagementSystemTest >> testGetPeopleOnEmptySystem [
self assert: self personSystem people isEmpty
]
2 changes: 1 addition & 1 deletion source/TeamsAPI-Core-Tests/PersonTest.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : #PersonTest,
#superclass : #TestCase,
#category : #'TeamsAPI-Core-Tests'
#category : #'TeamsAPI-Core-Tests-Model'
}

{ #category : #tests }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
A TeamSystemTest is a test class for testing the behavior of TeamSystem
"
Class {
#name : #TeamSystemTest,
#name : #TeamManagementSystemTest,
#superclass : #TestCase,
#instVars : [
'person',
'anotherPerson',
'rootSystem'
],
#category : #'TeamsAPI-Core-Tests'
#category : #'TeamsAPI-Core-Tests-Systems'
}

{ #category : #running }
TeamSystemTest >> setUp [
TeamManagementSystemTest >> setUp [
super setUp.
person := Person
named: 'Lucas'
Expand All @@ -25,18 +25,18 @@ TeamSystemTest >> setUp [
withEmailAddress: '[email protected]'.
rootSystem := CompositeSystem new.
rootSystem
register: PersonSystem new;
register: TeamSystem new;
register: PeopleManagementSystem new;
register: TeamManagementSystem new;
startUp
]

{ #category : #tests }
TeamSystemTest >> teamSystem [
TeamManagementSystemTest >> teamSystem [
^ rootSystem systemImplementing: #TeamSystemInterface
]

{ #category : #tests }
TeamSystemTest >> testAddTeam [
TeamManagementSystemTest >> testAddTeam [
| team teamSystem |
team := Team
named: 'Linces'
Expand All @@ -49,7 +49,7 @@ TeamSystemTest >> testAddTeam [
]

{ #category : #tests }
TeamSystemTest >> testDeleteATeamAlreadyDeleted [
TeamManagementSystemTest >> testDeleteATeamAlreadyDeleted [
| team teamSystem |
team := Team
named: 'Linces'
Expand All @@ -71,7 +71,7 @@ TeamSystemTest >> testDeleteATeamAlreadyDeleted [
]

{ #category : #tests }
TeamSystemTest >> testDeleteTeam [
TeamManagementSystemTest >> testDeleteTeam [
| team teamSystem |
team := Team
named: 'Linces'
Expand All @@ -86,7 +86,7 @@ TeamSystemTest >> testDeleteTeam [
]

{ #category : #tests }
TeamSystemTest >> testFailToAddTeamWithNamedAlreadyUsed [
TeamManagementSystemTest >> testFailToAddTeamWithNamedAlreadyUsed [
| team teamWithSameName teamSystem |
team := Team
named: 'Linces'
Expand All @@ -109,6 +109,6 @@ TeamSystemTest >> testFailToAddTeamWithNamedAlreadyUsed [
]

{ #category : #tests }
TeamSystemTest >> testGetTeamsOnEmptySystem [
TeamManagementSystemTest >> testGetTeamsOnEmptySystem [
self assert: self teamSystem teams isEmpty
]
2 changes: 1 addition & 1 deletion source/TeamsAPI-Core-Tests/TeamTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Class {
#instVars : [
'defaultPerson'
],
#category : #'TeamsAPI-Core-Tests'
#category : #'TeamsAPI-Core-Tests-Model'
}

{ #category : #initialization }
Expand Down
2 changes: 1 addition & 1 deletion source/TeamsAPI-Core/ManifestTeamsAPISystem.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : #ManifestTeamsAPISystem,
#superclass : #PackageManifest,
#category : #'TeamsAPI-Core'
#category : #'TeamsAPI-Core-Systems'
}

{ #category : #'class initialization' }
Expand Down
Loading