Skip to content

Commit

Permalink
Apply code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Jun 15, 2021
1 parent 88acee2 commit c65699a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Class {
#category : #'Stargate-Examples-Tests-Currencies'
}

{ #category : #'private - support' }
SouthAmericanCurrenciesRESTfulControllerTest >> assertThereAreNoLinksIn: json [

self assert: json links isNil
]

{ #category : #'private - support' }
SouthAmericanCurrenciesRESTfulControllerTest >> baseUrl [

Expand Down Expand Up @@ -72,7 +78,7 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetArgentinePeso [
assert: json name equals: 'Argentine peso';
assert: json symbol equals: '$';
assert: json isoCode equals: 'ARS';
assert: json links isNil
assertThereAreNoLinksIn: json
]
]

Expand Down Expand Up @@ -131,7 +137,7 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetArgentinePesoInEnglish [
assert: json name equals: 'Argentine peso';
assert: json symbol equals: '$';
assert: json isoCode equals: 'ARS';
assert: json links isNil
assertThereAreNoLinksIn: json
]
]

Expand Down Expand Up @@ -165,7 +171,7 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetArgentinePesoInSpanish [
assert: json name equals: 'Peso';
assert: json symbol equals: '$';
assert: json isoCode equals: 'ARS';
assert: json links isNil
assertThereAreNoLinksIn: json
]
]

Expand Down Expand Up @@ -197,7 +203,7 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetBrazilianReal [
assert: json name equals: 'Brazilian real';
assert: json symbol equals: 'R$';
assert: json isoCode equals: 'BRL';
assert: json links isNil
assertThereAreNoLinksIn: json
]
]

Expand Down Expand Up @@ -231,7 +237,7 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetBrazilianRealInEnglish [
assert: json name equals: 'Brazilian real';
assert: json symbol equals: 'R$';
assert: json isoCode equals: 'BRL';
assert: json links isNil
assertThereAreNoLinksIn: json
]
]

Expand Down Expand Up @@ -265,7 +271,7 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetBrazilianRealInSpanish [
assert: json name equals: 'Real brasileño';
assert: json symbol equals: 'R$';
assert: json isoCode equals: 'BRL';
assert: json links isNil
assertThereAreNoLinksIn: json
]
]

Expand Down
2 changes: 1 addition & 1 deletion source/Stargate-JSON-RPC/JsonRPCRequestHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ JsonRPCRequestHandler >> initialize [
super initialize.
messageProcessor := JRPCMessageProcessor new.
acceptNegotiator := RESTfulControllerAcceptNegotiator
basedOn: ( Array with: ZnMimeType applicationJson )
accepting: ( Array with: ZnMimeType applicationJson )
]

{ #category : #initialization }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RESTfulControllerAcceptNegotiatorTest >> assertBestRepresentationFor: anAcceptHe
{ #category : #'private - accessing' }
RESTfulControllerAcceptNegotiatorTest >> bestLanguageFor: aLanguageProrityList given: theAvailableLanguageTags [

^ ( RESTfulControllerAcceptNegotiator basedOn: #() and: theAvailableLanguageTags )
^ ( RESTfulControllerAcceptNegotiator accepting: #() inAnyOf: theAvailableLanguageTags )
bestLanguageFor:
( ( ZnRequest get: '/example' asZnUrl )
setAcceptLanguage: aLanguageProrityList;
Expand All @@ -41,7 +41,7 @@ RESTfulControllerAcceptNegotiatorTest >> bestLanguageFor: aLanguageProrityList g
{ #category : #'private - accessing' }
RESTfulControllerAcceptNegotiatorTest >> bestRepresentationFor: anAcceptHeaderContent given: theAvailableMediaTypes [

^ (RESTfulControllerAcceptNegotiator basedOn: theAvailableMediaTypes)
^ (RESTfulControllerAcceptNegotiator accepting: theAvailableMediaTypes)
bestRepresentationFor:
((ZnRequest get: '/example' asZnUrl)
setAccept: anAcceptHeaderContent;
Expand Down Expand Up @@ -94,7 +94,7 @@ RESTfulControllerAcceptNegotiatorTest >> testAcceptHeaderContentIsAnArray [
with: Character lf asString ) readStream.

self
assert: ( ( RESTfulControllerAcceptNegotiator basedOn: apiMediaTypes ) bestRepresentationFor: request )
assert: ( ( RESTfulControllerAcceptNegotiator accepting: apiMediaTypes ) bestRepresentationFor: request )
equals: 'application/vnd.stargate.pet+json;version=2.0.0' asMediaType
]

Expand Down
10 changes: 5 additions & 5 deletions source/Stargate-Model/RESTfulControllerAcceptNegotiator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Class {
}

{ #category : #'instance creation' }
RESTfulControllerAcceptNegotiator class >> basedOn: aMediaTypeCollection [
RESTfulControllerAcceptNegotiator class >> accepting: aMediaTypeCollection [

^ self new initializeBasedOn: aMediaTypeCollection and: #()
^ self accepting: aMediaTypeCollection inAnyOf: #()
]

{ #category : #'instance creation' }
RESTfulControllerAcceptNegotiator class >> basedOn: aMediaTypeCollection and: aLanguageTagCollection [
RESTfulControllerAcceptNegotiator class >> accepting: aMediaTypeCollection inAnyOf: aLanguageTagCollection [

^ self new initializeBasedOn: aMediaTypeCollection and: aLanguageTagCollection
^ self new initializeAccepting: aMediaTypeCollection inAnyOf: aLanguageTagCollection
]

{ #category : #'private - accessing' }
Expand Down Expand Up @@ -86,7 +86,7 @@ RESTfulControllerAcceptNegotiator >> bestRepresentationFor: anHttpRequest [
]

{ #category : #'initialize - release' }
RESTfulControllerAcceptNegotiator >> initializeBasedOn: aMediaTypeCollection and: aLanguageTagCollection [
RESTfulControllerAcceptNegotiator >> initializeAccepting: aMediaTypeCollection inAnyOf: aLanguageTagCollection [

availableMediaTypes := aMediaTypeCollection.
availableLanguageTags := aLanguageTagCollection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ RESTfulRequestHandlerBehavior >> initializeResourceLocator: aResouceLocator
paginationPolicy := aPaginationPolicy cull: self.
decodingRules := theDecodingRules.
encodingRules := theEncodingRules.
acceptNegotiator := RESTfulControllerAcceptNegotiator basedOn: encodingRules keys and: allowedLanguageTags.
acceptNegotiator := RESTfulControllerAcceptNegotiator accepting: encodingRules keys inAnyOf: allowedLanguageTags.
entityTagCalculator := anEntityTagCalculator.
cachingDirectives := theCachingDirectives
]
Expand Down

0 comments on commit c65699a

Please sign in to comment.