From b1d13ec34c7878c226d4a86297c6bdc76f25ceb2 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Fri, 14 Jun 2024 18:47:37 -0300 Subject: [PATCH 1/4] Add suppor for CURIEs Allow relation types in WebLinks to be also URLs and CURIEs --- .../ZnClient.extension.st | 16 +- .../ZnEntity.extension.st | 4 +- .../ZnMimeType.extension.st | 10 +- .../ZnRequest.extension.st | 18 +-- .../ZnResponse.extension.st | 26 ++-- .../ZnSingleThreadedServer.extension.st | 6 +- .../Hyperspace-Extensions/ZnUrl.extension.st | 24 ++- source/Hyperspace-Extensions/package.st | 2 +- .../AbstractCURIETest.class.st | 137 ++++++++++++++++++ .../Hyperspace-Model-Tests/CURIETest.class.st | 72 +++++++++ .../EntityTagTest.class.st | 20 +-- .../HTTPClientErrorTest.class.st | 32 ++-- .../HTTPErrorTest.class.st | 14 +- .../HTTPNotAcceptableTest.class.st | 10 +- .../HTTPServerErrorTest.class.st | 22 +-- .../LanguageRangeTest.class.st | 18 ++- .../LanguageTagTest.class.st | 26 ++-- .../MediaTypeTest.class.st | 16 +- .../PortAvailabilityCheckerTest.class.st | 20 +-- .../Hyperspace-Model-Tests/RetryTest.class.st | 62 ++++---- .../SafeCURIETest.class.st | 82 +++++++++++ .../WebLinkTest.class.st | 75 +++++++--- .../ZnClientHyperspaceExtensionsTest.class.st | 22 +-- .../ZnEntityHyperspaceExtensionsTest.class.st | 14 +- ...nMimeTypeHyperspaceExtensionsTest.class.st | 10 +- ...ZnRequestHyperspaceExtensionsTest.class.st | 26 ++-- ...nResponseHyperspaceExtensionsTest.class.st | 40 ++--- .../ZnServerHyperspaceExtensionsTest.class.st | 10 +- .../ZnUrlHyperspaceExtensionsTest.class.st | 18 ++- source/Hyperspace-Model-Tests/package.st | 2 +- .../Hyperspace-Model/AbstractCURIE.class.st | 74 ++++++++++ source/Hyperspace-Model/CURIE.class.st | 101 +++++++++++++ source/Hyperspace-Model/EntityTag.class.st | 34 +++-- .../ExceptionSelectorSet.class.st | 14 +- .../Hyperspace-Model/HTTPClientError.class.st | 24 +-- source/Hyperspace-Model/HTTPError.class.st | 20 +-- .../HTTPNotAcceptable.class.st | 22 +-- .../Hyperspace-Model/HTTPServerError.class.st | 14 +- .../Hyperspace-Model/LanguageRange.class.st | 30 ++-- source/Hyperspace-Model/LanguageTag.class.st | 44 +++--- .../MultiValueOrderedDictionary.class.st | 12 +- .../PortAvailabilityChecker.class.st | 14 +- source/Hyperspace-Model/Retry.class.st | 42 +++--- source/Hyperspace-Model/SafeCURIE.class.st | 94 ++++++++++++ source/Hyperspace-Model/WebLink.class.st | 126 ++++++++-------- source/Hyperspace-Model/package.st | 2 +- 46 files changed, 1091 insertions(+), 430 deletions(-) create mode 100644 source/Hyperspace-Model-Tests/AbstractCURIETest.class.st create mode 100644 source/Hyperspace-Model-Tests/CURIETest.class.st create mode 100644 source/Hyperspace-Model-Tests/SafeCURIETest.class.st create mode 100644 source/Hyperspace-Model/AbstractCURIE.class.st create mode 100644 source/Hyperspace-Model/CURIE.class.st create mode 100644 source/Hyperspace-Model/SafeCURIE.class.st diff --git a/source/Hyperspace-Extensions/ZnClient.extension.st b/source/Hyperspace-Extensions/ZnClient.extension.st index a955d1d..dbf7e86 100644 --- a/source/Hyperspace-Extensions/ZnClient.extension.st +++ b/source/Hyperspace-Extensions/ZnClient.extension.st @@ -1,12 +1,12 @@ -Extension { #name : #ZnClient } +Extension { #name : 'ZnClient' } -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnClient >> logLevel [ ^ logLevel ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnClient >> query [ "Execute an HTTP QUERY the request set up and return the response #contents." @@ -17,32 +17,32 @@ ZnClient >> query [ ] ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnClient >> resetRequest [ request := ZnRequest empty. response := nil ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnClient >> setAccept: object [ request setAccept: object ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnClient >> setIfMatchTo: etag [ request setIfMatchTo: etag ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnClient >> setIfNoneMatchTo: etag [ request setIfNoneMatchTo: etag ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnClient >> setLogLevelAtLeastTo: integer [ self logLevel: (integer max: logLevel) diff --git a/source/Hyperspace-Extensions/ZnEntity.extension.st b/source/Hyperspace-Extensions/ZnEntity.extension.st index 264aeef..bba41d8 100644 --- a/source/Hyperspace-Extensions/ZnEntity.extension.st +++ b/source/Hyperspace-Extensions/ZnEntity.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #ZnEntity } +Extension { #name : 'ZnEntity' } -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnEntity class >> with: anObject ofType: aMimeType [ | entity | diff --git a/source/Hyperspace-Extensions/ZnMimeType.extension.st b/source/Hyperspace-Extensions/ZnMimeType.extension.st index 206b41e..012b120 100644 --- a/source/Hyperspace-Extensions/ZnMimeType.extension.st +++ b/source/Hyperspace-Extensions/ZnMimeType.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #ZnMimeType } +Extension { #name : 'ZnMimeType' } -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnMimeType >> accepts: aMimeType [ ^ (aMimeType main = '*' or: [ aMimeType main = self main ]) and: [ @@ -9,19 +9,19 @@ ZnMimeType >> accepts: aMimeType [ ($+ split: self sub) includes: aMimeType sub ] ] ] ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnMimeType >> asMediaType [ ^ self ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnMimeType >> quality [ ^ Float readFrom: (self parameterAt: 'q' ifAbsent: [ ^1.0 ]) ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnMimeType >> version: aVersionString [ self parameters at: 'version' put: aVersionString diff --git a/source/Hyperspace-Extensions/ZnRequest.extension.st b/source/Hyperspace-Extensions/ZnRequest.extension.st index 4975632..76847b8 100644 --- a/source/Hyperspace-Extensions/ZnRequest.extension.st +++ b/source/Hyperspace-Extensions/ZnRequest.extension.st @@ -1,48 +1,48 @@ -Extension { #name : #ZnRequest } +Extension { #name : 'ZnRequest' } -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnRequest >> acceptLanguage [ ^ self headers at: 'Accept-Language' ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnRequest >> hasLanguageProrityList [ ^ self headers includesKey: 'Accept-Language' ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnRequest class >> query: urlObject [ ^ self supportQUERYDuring: [ self method: #QUERY url: urlObject ] ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnRequest >> readFrom: stream [ ^ self class supportQUERYDuring: [ super readFrom: stream ] ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnRequest >> setAcceptLanguage: acceptLanguageDirectives [ self headers at: 'Accept-Language' put: acceptLanguageDirectives asString ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnRequest >> setIfMatchTo: etag [ self headers at: 'If-Match' put: etag asString ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnRequest >> setIfNoneMatchTo: etag [ self headers at: 'If-None-Match' put: etag asString ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnRequest class >> supportQUERYDuring: aBlock [ ^ aBlock diff --git a/source/Hyperspace-Extensions/ZnResponse.extension.st b/source/Hyperspace-Extensions/ZnResponse.extension.st index 6918699..5c13ff5 100644 --- a/source/Hyperspace-Extensions/ZnResponse.extension.st +++ b/source/Hyperspace-Extensions/ZnResponse.extension.st @@ -1,30 +1,30 @@ -Extension { #name : #ZnResponse } +Extension { #name : 'ZnResponse' } -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> addCachingDirective: aDirective [ self headers at: 'Cache-Control' add: aDirective ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> addContentLanguage: aLanguageTag [ self headers at: 'Content-Language' add: aLanguageTag ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> addLink: aLink [ self headers at: 'Link' add: aLink ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> addToVary: headerName [ self headers at: 'Vary' add: headerName ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> cachingDirectives [ | directives | @@ -35,7 +35,7 @@ ZnResponse >> cachingDirectives [ ifFalse: [ Array with: directives ] ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> contentLanguageTags [ | headerValue | @@ -46,19 +46,19 @@ ZnResponse >> contentLanguageTags [ ifFalse: [ Array with: headerValue asLanguageTag ] ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> entityTag [ ^ (self headers at: 'ETag') asEntityTag ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> hasLocation [ ^ self headers includesKey: 'Location' ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> links [ | headerValue | @@ -69,13 +69,13 @@ ZnResponse >> links [ ifFalse: [ Array with: headerValue asWebLink ] ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> setEntityTag: aStringOrEntityTag [ self headers at: 'ETag' put: aStringOrEntityTag asEntityTag asString ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> varyHeaderNames [ | headerValue | @@ -86,7 +86,7 @@ ZnResponse >> varyHeaderNames [ ifFalse: [ Array with: headerValue ] ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnResponse >> withEntityTagDo: foundBlock ifAbsent: absentBlock [ self headers at: 'ETag' ifPresent: [ :headerValue | ^ foundBlock cull: headerValue asEntityTag ]. diff --git a/source/Hyperspace-Extensions/ZnSingleThreadedServer.extension.st b/source/Hyperspace-Extensions/ZnSingleThreadedServer.extension.st index 88c505d..57ed7d0 100644 --- a/source/Hyperspace-Extensions/ZnSingleThreadedServer.extension.st +++ b/source/Hyperspace-Extensions/ZnSingleThreadedServer.extension.st @@ -1,12 +1,12 @@ -Extension { #name : #ZnSingleThreadedServer } +Extension { #name : 'ZnSingleThreadedServer' } -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnSingleThreadedServer >> logLevel [ ^ logLevel ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnSingleThreadedServer >> setLogLevelAtLeastTo: integer [ self logLevel: (integer max: logLevel) diff --git a/source/Hyperspace-Extensions/ZnUrl.extension.st b/source/Hyperspace-Extensions/ZnUrl.extension.st index 6fb9e6d..614c88b 100644 --- a/source/Hyperspace-Extensions/ZnUrl.extension.st +++ b/source/Hyperspace-Extensions/ZnUrl.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #ZnUrl } +Extension { #name : 'ZnUrl' } -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnUrl >> asAbsoluteUrl [ AssertionChecker @@ -11,7 +11,7 @@ ZnUrl >> asAbsoluteUrl [ ^ self ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnUrl >> asHostedAt: aBaseUrl [ ^ self copy @@ -21,13 +21,19 @@ ZnUrl >> asHostedAt: aBaseUrl [ yourself ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnUrl >> asWebLink [ ^ WebLink to: self ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } +ZnUrl >> expandToURIIn: context [ + + ^ self +] + +{ #category : '*Hyperspace-Extensions' } ZnUrl >> queryAt: aKey putUrl: anUnencodedUrl [ | encodedUrl | @@ -36,10 +42,16 @@ ZnUrl >> queryAt: aKey putUrl: anUnencodedUrl [ ^ self queryAt: aKey put: encodedUrl ] -{ #category : #'*Hyperspace-Extensions' } +{ #category : '*Hyperspace-Extensions' } ZnUrl >> start: startIndex limit: limitCount [ self queryAt: 'start' put: startIndex; queryAt: 'limit' put: limitCount ] + +{ #category : '*Hyperspace-Extensions' } +ZnUrl >> withFragment: string [ + + ^ self copy fragment: string +] diff --git a/source/Hyperspace-Extensions/package.st b/source/Hyperspace-Extensions/package.st index 28205ee..ab9c0b4 100644 --- a/source/Hyperspace-Extensions/package.st +++ b/source/Hyperspace-Extensions/package.st @@ -1 +1 @@ -Package { #name : #'Hyperspace-Extensions' } +Package { #name : 'Hyperspace-Extensions' } diff --git a/source/Hyperspace-Model-Tests/AbstractCURIETest.class.st b/source/Hyperspace-Model-Tests/AbstractCURIETest.class.st new file mode 100644 index 0000000..a4deada --- /dev/null +++ b/source/Hyperspace-Model-Tests/AbstractCURIETest.class.st @@ -0,0 +1,137 @@ +" +An AbstractCURIETest is a test class for testing the behavior of AbstractCURIE +" +Class { + #name : 'AbstractCURIETest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests', + #package : 'Hyperspace-Model-Tests' +} + +{ #category : 'testing' } +AbstractCURIETest class >> isAbstract [ + + ^ self = AbstractCURIETest +] + +{ #category : 'private' } +AbstractCURIETest >> curieClass [ + + ^ self subclassResponsibility +] + +{ #category : 'tests' } +AbstractCURIETest >> testAccessing [ + + | curie | + curie := self curieClass prefixedBy: 'schema' referencing: 'Person' asUrl. + + self + assert: curie prefix equals: 'schema'; + assertUrl: curie relativeReference equals: 'Person' asUrl. + + + curie := self curieClass prefixedBy: 'schema' referencing: 'Person#legal' asUrl. + + self + assert: curie prefix equals: 'schema'; + assertUrl: curie relativeReference equals: 'Person#legal' asUrl +] + +{ #category : 'tests' } +AbstractCURIETest >> testAsWebLink [ + + | curie | + curie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + self assert: curie asWebLink equals: ( WebLink to: curie ) +] + +{ #category : 'tests' } +AbstractCURIETest >> testCantCreateWithAbsoluteReference [ + + self + should: [ self curieClass prefixedBy: 'users' referencing: 'https://google.com/' asUrl ] + raise: InstanceCreationFailed + withMessageText: 'https://google.com/ must be a relative reference' +] + +{ #category : 'tests' } +AbstractCURIETest >> testCantCreateWithEmptyPrefix [ + + self + should: [ self curieClass prefixedBy: '' referencing: 'octocat' asUrl ] + raise: InstanceCreationFailed + withMessageText: 'A CURIE prefix cannot be empty' +] + +{ #category : 'tests' } +AbstractCURIETest >> testCantExpandToURIInContext [ + + | curie | + curie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + + self + should: [ curie expandToURIIn: Dictionary new ] + raise: ObjectNotFound + withMessageText: 'Missing namespace "users"' +] + +{ #category : 'tests' } +AbstractCURIETest >> testCantExpandToURIInContextRecursiverly [ + + | userCurie usersCurie context | + usersCurie := self curieClass prefixedBy: 'api' referencing: 'users' asUrl. + userCurie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + + context := Dictionary new. + context at: 'users' put: usersCurie. + self + should: [ userCurie expandToURIIn: context ] + raise: ObjectNotFound + withMessageText: 'Missing namespace "api"' +] + +{ #category : 'tests' } +AbstractCURIETest >> testComparing [ + + | curie | + curie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + + self assert: curie equals: curie. + + self + assert: curie equals: ( self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl ); + assert: curie hash + equals: ( self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl ) hash; + deny: curie equals: ( self curieClass prefixedBy: 'users' referencing: 'hexacat' asUrl ); + deny: curie equals: ( self curieClass prefixedBy: 'orgs' referencing: 'octocat' asUrl ) +] + +{ #category : 'tests' } +AbstractCURIETest >> testExpandToURIInContext [ + + | curie context | + curie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + + context := Dictionary new. + context at: 'users' put: 'https://api.github.com/users/' asUrl. + self + assertUrl: ( curie expandToURIIn: context ) + equals: 'https://api.github.com/users/octocat' asUrl +] + +{ #category : 'tests' } +AbstractCURIETest >> testExpandToURIInContextRecursively [ + + | usersCurie userCurie context | + usersCurie := self curieClass prefixedBy: 'api' referencing: 'users' asUrl. + userCurie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + + context := Dictionary new. + context at: 'api' put: 'https://api.github.com' asUrl. + context at: 'users' put: usersCurie. + + self + assertUrl: ( userCurie expandToURIIn: context ) + equals: 'https://api.github.com/users/octocat' asUrl +] diff --git a/source/Hyperspace-Model-Tests/CURIETest.class.st b/source/Hyperspace-Model-Tests/CURIETest.class.st new file mode 100644 index 0000000..b90dbb2 --- /dev/null +++ b/source/Hyperspace-Model-Tests/CURIETest.class.st @@ -0,0 +1,72 @@ +" +A CompactURITest is a test class for testing the behavior of CompactURI +" +Class { + #name : 'CURIETest', + #superclass : 'AbstractCURIETest', + #category : 'Hyperspace-Model-Tests', + #package : 'Hyperspace-Model-Tests' +} + +{ #category : 'private' } +CURIETest >> curieClass [ + + ^ CURIE +] + +{ #category : 'tests' } +CURIETest >> testAsSafeCURIE [ + + self + assert: ( self curieClass fromString: 'users:octocat' ) asSafeCURIE printString + equals: '[users:octocat]' +] + +{ #category : 'tests' } +CURIETest >> testFromString [ + + | curie | + curie := self curieClass fromString: 'users:octocat/tokens'. + + self + assert: curie prefix equals: 'users'; + assertUrl: curie relativeReference equals: 'octocat' asUrl / 'tokens' +] + +{ #category : 'tests' } +CURIETest >> testParsingErrors [ + + self + should: [ self curieClass fromString: ':' ] + raise: InstanceCreationFailed + withMessageText: 'A CURIE prefix cannot be empty'; + should: [ self curieClass fromString: '' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a CURIE from ""'; + should: [ self curieClass fromString: 'users:octocat:AAA' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a CURIE from "users:octocat:AAA"'; + should: [ self curieClass fromString: 'users' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a CURIE from "users"' +] + +{ #category : 'tests' } +CURIETest >> testPrinting [ + + | curie curieWithPath curieWithFragment | + + self assert: ( self curieClass fromString: 'users:' ) printString equals: 'users:'. + + curie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + + self assert: curie printString equals: 'users:octocat'. + + curieWithPath := curie / 'addresses'. + + self assert: curieWithPath printString equals: 'users:octocat/addresses'. + + curieWithFragment := curieWithPath withFragment: 'primary'. + + self assert: curieWithFragment printString equals: 'users:octocat/addresses#primary' +] diff --git a/source/Hyperspace-Model-Tests/EntityTagTest.class.st b/source/Hyperspace-Model-Tests/EntityTagTest.class.st index e2444cc..d8392df 100644 --- a/source/Hyperspace-Model-Tests/EntityTagTest.class.st +++ b/source/Hyperspace-Model-Tests/EntityTagTest.class.st @@ -2,12 +2,14 @@ I'm a test case for EntityTag " Class { - #name : #EntityTagTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-IETF' + #name : 'EntityTagTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-IETF', + #package : 'Hyperspace-Model-Tests', + #tag : 'IETF' } -{ #category : #tests } +{ #category : 'tests' } EntityTagTest >> testAsEntityTag [ self @@ -15,14 +17,14 @@ EntityTagTest >> testAsEntityTag [ assert: (EntityTag fromString: '"12345"') asEntityTag equals: (EntityTag fromString: '"12345"') ] -{ #category : #tests } +{ #category : 'tests' } EntityTagTest >> testAsString [ self assert: (EntityTag with: '12345') asString equals: '"12345"'. self assert: (EntityTag weakWith: '12345') asString equals: 'W/"12345"'. ] -{ #category : #tests } +{ #category : 'tests' } EntityTagTest >> testCaseSensitiveWeakEntityTagCreation [ self @@ -31,7 +33,7 @@ EntityTagTest >> testCaseSensitiveWeakEntityTagCreation [ raise: InstanceCreationFailed ] -{ #category : #tests } +{ #category : 'tests' } EntityTagTest >> testFromString [ self @@ -49,7 +51,7 @@ EntityTagTest >> testFromString [ should: [ EntityTag fromString: 'w/"1"' ] raise: InstanceCreationFailed ] -{ #category : #tests } +{ #category : 'tests' } EntityTagTest >> testHash [ self @@ -60,7 +62,7 @@ EntityTagTest >> testHash [ equals: (EntityTag fromString: 'W/"12345"') hash ] -{ #category : #tests } +{ #category : 'tests' } EntityTagTest >> testPrinting [ self assert: (EntityTag with: '12345') printString equals: '"12345"'. diff --git a/source/Hyperspace-Model-Tests/HTTPClientErrorTest.class.st b/source/Hyperspace-Model-Tests/HTTPClientErrorTest.class.st index d0b6896..887aa10 100644 --- a/source/Hyperspace-Model-Tests/HTTPClientErrorTest.class.st +++ b/source/Hyperspace-Model-Tests/HTTPClientErrorTest.class.st @@ -2,12 +2,14 @@ A HTTPClientErrorTest is a test class for testing the behavior of HTTPClientError " Class { - #name : #HTTPClientErrorTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Exceptions' + #name : 'HTTPClientErrorTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Exceptions', + #package : 'Hyperspace-Model-Tests', + #tag : 'Exceptions' } -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testBadRequest [ self @@ -21,7 +23,7 @@ HTTPClientErrorTest >> testBadRequest [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testConflict [ self @@ -35,7 +37,7 @@ HTTPClientErrorTest >> testConflict [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testConvenienceHandler [ self @@ -48,7 +50,7 @@ HTTPClientErrorTest >> testConvenienceHandler [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testConvenienceHandlerUsingAnotherSignal [ self @@ -64,7 +66,7 @@ HTTPClientErrorTest >> testConvenienceHandlerUsingAnotherSignal [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testConvenienceHandlerWithOnExceptDo [ self @@ -81,7 +83,7 @@ HTTPClientErrorTest >> testConvenienceHandlerWithOnExceptDo [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testNotFound [ self @@ -104,7 +106,7 @@ HTTPClientErrorTest >> testNotFound [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testPreconditionFailed [ self @@ -118,7 +120,7 @@ HTTPClientErrorTest >> testPreconditionFailed [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testPreconditionRequired [ self @@ -132,7 +134,7 @@ HTTPClientErrorTest >> testPreconditionRequired [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testSignalingCustomCode [ self @@ -151,7 +153,7 @@ HTTPClientErrorTest >> testSignalingCustomCode [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testTooManyRequests [ self @@ -165,7 +167,7 @@ HTTPClientErrorTest >> testTooManyRequests [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testUnprocessableEntity [ self @@ -179,7 +181,7 @@ HTTPClientErrorTest >> testUnprocessableEntity [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPClientErrorTest >> testUnsupportedMediaType [ self diff --git a/source/Hyperspace-Model-Tests/HTTPErrorTest.class.st b/source/Hyperspace-Model-Tests/HTTPErrorTest.class.st index d00c7f2..abcefb1 100644 --- a/source/Hyperspace-Model-Tests/HTTPErrorTest.class.st +++ b/source/Hyperspace-Model-Tests/HTTPErrorTest.class.st @@ -2,12 +2,14 @@ A HTTPErrorTest is a test class for testing the behavior of HTTPError " Class { - #name : #HTTPErrorTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Exceptions' + #name : 'HTTPErrorTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Exceptions', + #package : 'Hyperspace-Model-Tests', + #tag : 'Exceptions' } -{ #category : #tests } +{ #category : 'tests' } HTTPErrorTest >> testHandlingExceptionSelectorSets [ self @@ -24,13 +26,13 @@ HTTPErrorTest >> testHandlingExceptionSelectorSets [ raise: HTTPServerError serviceUnavailable ] -{ #category : #tests } +{ #category : 'tests' } HTTPErrorTest >> testHandlingHTTPClientError [ self should: [ HTTPClientError notFound signal ] raise: HTTPError ] -{ #category : #tests } +{ #category : 'tests' } HTTPErrorTest >> testHandlingHTTPServerError [ self should: [ HTTPServerError internalServerError signal ] raise: HTTPError diff --git a/source/Hyperspace-Model-Tests/HTTPNotAcceptableTest.class.st b/source/Hyperspace-Model-Tests/HTTPNotAcceptableTest.class.st index 8e5829a..c1683ed 100644 --- a/source/Hyperspace-Model-Tests/HTTPNotAcceptableTest.class.st +++ b/source/Hyperspace-Model-Tests/HTTPNotAcceptableTest.class.st @@ -1,10 +1,12 @@ Class { - #name : #HTTPNotAcceptableTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Exceptions' + #name : 'HTTPNotAcceptableTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Exceptions', + #package : 'Hyperspace-Model-Tests', + #tag : 'Exceptions' } -{ #category : #tests } +{ #category : 'tests' } HTTPNotAcceptableTest >> testSignaling [ self diff --git a/source/Hyperspace-Model-Tests/HTTPServerErrorTest.class.st b/source/Hyperspace-Model-Tests/HTTPServerErrorTest.class.st index ff11a12..512d986 100644 --- a/source/Hyperspace-Model-Tests/HTTPServerErrorTest.class.st +++ b/source/Hyperspace-Model-Tests/HTTPServerErrorTest.class.st @@ -2,12 +2,14 @@ A HTTPServerErrorTest is a test class for testing the behavior of HTTPServerError " Class { - #name : #HTTPServerErrorTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Exceptions' + #name : 'HTTPServerErrorTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Exceptions', + #package : 'Hyperspace-Model-Tests', + #tag : 'Exceptions' } -{ #category : #tests } +{ #category : 'tests' } HTTPServerErrorTest >> testConvenienceHandler [ self @@ -20,7 +22,7 @@ HTTPServerErrorTest >> testConvenienceHandler [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPServerErrorTest >> testConvenienceHandlerUsingAnotherSignal [ self @@ -32,7 +34,7 @@ HTTPServerErrorTest >> testConvenienceHandlerUsingAnotherSignal [ withExceptionDo: [ :signal | self assert: signal code equals: 503 ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPServerErrorTest >> testExceptionExclusion [ self @@ -56,7 +58,7 @@ HTTPServerErrorTest >> testExceptionExclusion [ withExceptionDo: [ :signal | self assert: signal code equals: 503 ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPServerErrorTest >> testInternalServerError [ self @@ -70,7 +72,7 @@ HTTPServerErrorTest >> testInternalServerError [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPServerErrorTest >> testInternalServerErrorDefaultMessageText [ self @@ -84,7 +86,7 @@ HTTPServerErrorTest >> testInternalServerErrorDefaultMessageText [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPServerErrorTest >> testServiceUnavailable [ self @@ -98,7 +100,7 @@ HTTPServerErrorTest >> testServiceUnavailable [ ] ] -{ #category : #tests } +{ #category : 'tests' } HTTPServerErrorTest >> testServiceUnavailableDefaultMessageText [ self diff --git a/source/Hyperspace-Model-Tests/LanguageRangeTest.class.st b/source/Hyperspace-Model-Tests/LanguageRangeTest.class.st index 9f3c919..1951ec5 100644 --- a/source/Hyperspace-Model-Tests/LanguageRangeTest.class.st +++ b/source/Hyperspace-Model-Tests/LanguageRangeTest.class.st @@ -2,12 +2,14 @@ A LanguageRangeTest is a test class for testing the behavior of LanguageRange " Class { - #name : #LanguageRangeTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-IETF' + #name : 'LanguageRangeTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-IETF', + #package : 'Hyperspace-Model-Tests', + #tag : 'IETF' } -{ #category : #tests } +{ #category : 'tests' } LanguageRangeTest >> testAny [ self @@ -17,7 +19,7 @@ LanguageRangeTest >> testAny [ assert: LanguageRange any subtags equals: #('*') ] -{ #category : #tests } +{ #category : 'tests' } LanguageRangeTest >> testAnyMatches [ | range | @@ -29,7 +31,7 @@ LanguageRangeTest >> testAnyMatches [ assert: ( range matches: 'es-ar' asLanguageTag ) ] -{ #category : #tests } +{ #category : 'tests' } LanguageRangeTest >> testComparison [ | range | @@ -42,7 +44,7 @@ LanguageRangeTest >> testComparison [ deny: range equals: ( LanguageRange from: #('en') ) ] -{ #category : #tests } +{ #category : 'tests' } LanguageRangeTest >> testCreation [ | range | @@ -53,7 +55,7 @@ LanguageRangeTest >> testCreation [ assert: range printString equals: 'en-Latn-US' ] -{ #category : #tests } +{ #category : 'tests' } LanguageRangeTest >> testMatches [ | range | diff --git a/source/Hyperspace-Model-Tests/LanguageTagTest.class.st b/source/Hyperspace-Model-Tests/LanguageTagTest.class.st index ca7cbad..cd16b54 100644 --- a/source/Hyperspace-Model-Tests/LanguageTagTest.class.st +++ b/source/Hyperspace-Model-Tests/LanguageTagTest.class.st @@ -2,12 +2,14 @@ A LanguageTagTest is a test class for testing the behavior of LanguageTag " Class { - #name : #LanguageTagTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-IETF' + #name : 'LanguageTagTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-IETF', + #package : 'Hyperspace-Model-Tests', + #tag : 'IETF' } -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCantCreateWhenLanguageCodeIsInvalid [ self @@ -19,7 +21,7 @@ LanguageTagTest >> testCantCreateWhenLanguageCodeIsInvalid [ withMessageText: 'ISO 639 language codes must consist only of letters.' ] -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCantCreateWhenRegionIsInvalid [ self @@ -28,7 +30,7 @@ LanguageTagTest >> testCantCreateWhenRegionIsInvalid [ withMessageText: 'Supported ISO 3166-1 codes must be 2 letters.' ] -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCantCreateWhenScriptIsInvalid [ self @@ -37,7 +39,7 @@ LanguageTagTest >> testCantCreateWhenScriptIsInvalid [ withMessageText: 'ISO 15924 script codes must be 4 letters.' ] -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCreation [ | tag | @@ -51,7 +53,7 @@ LanguageTagTest >> testCreation [ self assert: tag subtags equals: #('en' 'Latn' 'US') ] -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCreationWithExtensions [ | tag | @@ -67,7 +69,7 @@ LanguageTagTest >> testCreationWithExtensions [ equals: #('en' 'Latn' 'GB' 'boont' 'r' 'extended' 'sequence' 'x' 'private') ] -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCreationWithHorribleCase [ | tag | @@ -81,7 +83,7 @@ LanguageTagTest >> testCreationWithHorribleCase [ self assert: tag subtags equals: #('es' 'Latn' 'AR') ] -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCreationWithOnlyLanguage [ | tag | @@ -95,7 +97,7 @@ LanguageTagTest >> testCreationWithOnlyLanguage [ self assert: tag subtags equals: #('en') ] -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCreationWithRegionButNotScript [ | tag | @@ -109,7 +111,7 @@ LanguageTagTest >> testCreationWithRegionButNotScript [ self assert: tag subtags equals: #('en' 'US') ] -{ #category : #tests } +{ #category : 'tests' } LanguageTagTest >> testCreationWithScriptButNoRegion [ | tag | diff --git a/source/Hyperspace-Model-Tests/MediaTypeTest.class.st b/source/Hyperspace-Model-Tests/MediaTypeTest.class.st index 5f1f69b..f13fd36 100644 --- a/source/Hyperspace-Model-Tests/MediaTypeTest.class.st +++ b/source/Hyperspace-Model-Tests/MediaTypeTest.class.st @@ -2,12 +2,14 @@ I'm a test for media type extensions " Class { - #name : #MediaTypeTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-IETF' + #name : 'MediaTypeTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-IETF', + #package : 'Hyperspace-Model-Tests', + #tag : 'IETF' } -{ #category : #tests } +{ #category : 'tests' } MediaTypeTest >> testAccepts [ | mediaType | @@ -28,7 +30,7 @@ MediaTypeTest >> testAccepts [ deny: (mediaType accepts: 'application/xml' asMediaType) ] -{ #category : #tests } +{ #category : 'tests' } MediaTypeTest >> testAsMediaType [ | mediaType | @@ -38,7 +40,7 @@ MediaTypeTest >> testAsMediaType [ self assert: mediaType asMediaType identicalTo: mediaType ] -{ #category : #tests } +{ #category : 'tests' } MediaTypeTest >> testQuality [ self @@ -46,7 +48,7 @@ MediaTypeTest >> testQuality [ assert: 'text/html;q=0.8' asMediaType quality equals: 0.8 ] -{ #category : #tests } +{ #category : 'tests' } MediaTypeTest >> testVersion [ | mediaType | diff --git a/source/Hyperspace-Model-Tests/PortAvailabilityCheckerTest.class.st b/source/Hyperspace-Model-Tests/PortAvailabilityCheckerTest.class.st index 6b680cd..8a87c60 100644 --- a/source/Hyperspace-Model-Tests/PortAvailabilityCheckerTest.class.st +++ b/source/Hyperspace-Model-Tests/PortAvailabilityCheckerTest.class.st @@ -1,13 +1,15 @@ Class { - #name : #PortAvailabilityCheckerTest, - #superclass : #TestCase, + #name : 'PortAvailabilityCheckerTest', + #superclass : 'TestCase', #instVars : [ 'checker' ], - #category : #'Hyperspace-Model-Tests-Resilience' + #category : 'Hyperspace-Model-Tests-Resilience', + #package : 'Hyperspace-Model-Tests', + #tag : 'Resilience' } -{ #category : #'private - support' } +{ #category : 'private - support' } PortAvailabilityCheckerTest >> openSocketOn: aPortNumber during: aBlock [ | socket | @@ -16,14 +18,14 @@ PortAvailabilityCheckerTest >> openSocketOn: aPortNumber during: aBlock [ aBlock ensure: [ socket destroy ] ] -{ #category : #initialization } +{ #category : 'initialization' } PortAvailabilityCheckerTest >> setUp [ super setUp. checker := PortAvailabilityChecker new ] -{ #category : #'tests - TCP' } +{ #category : 'tests - TCP' } PortAvailabilityCheckerTest >> testIfIsAvailableForTCPIfNot [ | wasEvaluated | @@ -35,7 +37,7 @@ PortAvailabilityCheckerTest >> testIfIsAvailableForTCPIfNot [ self assert: wasEvaluated ] -{ #category : #'tests - TCP' } +{ #category : 'tests - TCP' } PortAvailabilityCheckerTest >> testIfIsAvailableForTCPIfNotWhenNotAvailable [ | port | @@ -49,13 +51,13 @@ PortAvailabilityCheckerTest >> testIfIsAvailableForTCPIfNotWhenNotAvailable [ ] ] -{ #category : #'tests - TCP' } +{ #category : 'tests - TCP' } PortAvailabilityCheckerTest >> testIsAvailableForTCP [ self assert: ( checker isAvailableForTCP: self freeListeningTCPPort ) ] -{ #category : #'tests - TCP' } +{ #category : 'tests - TCP' } PortAvailabilityCheckerTest >> testIsNotAvailableForTCP [ | port | diff --git a/source/Hyperspace-Model-Tests/RetryTest.class.st b/source/Hyperspace-Model-Tests/RetryTest.class.st index 992200b..b3eccd3 100644 --- a/source/Hyperspace-Model-Tests/RetryTest.class.st +++ b/source/Hyperspace-Model-Tests/RetryTest.class.st @@ -2,30 +2,32 @@ A RetryTest is a test class for testing the behavior of Retry " Class { - #name : #RetryTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Resilience' + #name : 'RetryTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Resilience', + #package : 'Hyperspace-Model-Tests', + #tag : 'Resilience' } -{ #category : #private } +{ #category : 'private' } RetryTest >> expectedError [ ^ HTTPClientError badRequest ] -{ #category : #private } +{ #category : 'private' } RetryTest >> shouldRaiseExpectedError: aBlock [ self should: aBlock raise: self expectedError withMessageText: 'Too bad' ] -{ #category : #private } +{ #category : 'private' } RetryTest >> signalExpectedError [ ^ self expectedError signal: 'Too bad' ] -{ #category : #'tests - configuring retry count' } +{ #category : 'tests - configuring retry count' } RetryTest >> testCannotUseNegativeRetries [ self should: [ Retry value: [ ] configuredBy: [ :retry | retry upTo: -1 ] ] @@ -33,7 +35,7 @@ RetryTest >> testCannotUseNegativeRetries [ withMessageText: 'The maximum number of retries must be strictly positive.' ] -{ #category : #'tests - configuring retry count' } +{ #category : 'tests - configuring retry count' } RetryTest >> testCannotUseZeroRetries [ self should: [ Retry value: [ ] configuredBy: [ :retry | retry upTo: 0 ] ] @@ -41,7 +43,7 @@ RetryTest >> testCannotUseZeroRetries [ withMessageText: 'The maximum number of retries must be strictly positive.' ] -{ #category : #'tests - configuring retry count' } +{ #category : 'tests - configuring retry count' } RetryTest >> testConfiguringRetryCountWhenRetriesNotNeeded [ | count | @@ -53,7 +55,7 @@ RetryTest >> testConfiguringRetryCountWhenRetriesNotNeeded [ self assert: count equals: 1 ] -{ #category : #'tests - configuring wait time' } +{ #category : 'tests - configuring wait time' } RetryTest >> testEvery [ | count runtime | @@ -80,7 +82,7 @@ RetryTest >> testEvery [ assert: runtime milliSeconds >= 200 milliSeconds ] -{ #category : #'tests - configuring wait time' } +{ #category : 'tests - configuring wait time' } RetryTest >> testExponentialBackoff [ | count runtime | @@ -107,7 +109,7 @@ RetryTest >> testExponentialBackoff [ assert: runtime milliSeconds >= (50 + 150) milliSeconds ] -{ #category : #'tests - configuring wait time' } +{ #category : 'tests - configuring wait time' } RetryTest >> testExponentialBackoffWithDefaultRandomGenerator [ | count | @@ -130,7 +132,7 @@ RetryTest >> testExponentialBackoffWithDefaultRandomGenerator [ self assert: count equals: 3 ] -{ #category : #tests } +{ #category : 'tests' } RetryTest >> testHooksOnRetries [ | count exceptionsDrivingRetries resultsDrivingRetries | @@ -168,7 +170,7 @@ RetryTest >> testHooksOnRetries [ assertCollection: resultsDrivingRetries hasSameElements: #( 1 3 ) ] -{ #category : #'tests - configuring condition' } +{ #category : 'tests - configuring condition' } RetryTest >> testHooksOnRetriesDueToCondition [ | count resultsDrivingRetries | @@ -195,7 +197,7 @@ RetryTest >> testHooksOnRetriesDueToCondition [ assertCollection: resultsDrivingRetries hasSameElements: #( 1 2 3 ) ] -{ #category : #'tests - configuring errors' } +{ #category : 'tests - configuring errors' } RetryTest >> testHooksOnRetriesDueToExpectedErrorRaised [ | count exceptionsDrivingRetries | @@ -230,7 +232,7 @@ RetryTest >> testHooksOnRetriesDueToExpectedErrorRaised [ ] ] -{ #category : #'tests - configuring errors' } +{ #category : 'tests - configuring errors' } RetryTest >> testIgnoreWhenExpectedErrorIsRaised [ | count | @@ -254,7 +256,7 @@ RetryTest >> testIgnoreWhenExpectedErrorIsRaised [ self assert: count equals: 2 ] -{ #category : #'tests - configuring errors' } +{ #category : 'tests - configuring errors' } RetryTest >> testIgnoreWhenUnexpectedErrorIsRaised [ | count | @@ -280,7 +282,7 @@ RetryTest >> testIgnoreWhenUnexpectedErrorIsRaised [ self assert: count equals: 1 ] -{ #category : #tests } +{ #category : 'tests' } RetryTest >> testMaximumNumberOfAttemptsIsSurpassed [ | count | @@ -297,7 +299,7 @@ RetryTest >> testMaximumNumberOfAttemptsIsSurpassed [ self assert: count equals: Retry defaultMaximumNumberOfAttempts ] -{ #category : #tests } +{ #category : 'tests' } RetryTest >> testNoNeedToRetry [ | count | @@ -309,7 +311,7 @@ RetryTest >> testNoNeedToRetry [ self assert: count equals: 1 ] -{ #category : #'tests - configuring errors' } +{ #category : 'tests - configuring errors' } RetryTest >> testOnWhenExpectedErrorIsRaised [ | count | @@ -332,7 +334,7 @@ RetryTest >> testOnWhenExpectedErrorIsRaised [ self assert: count equals: 2 ] -{ #category : #'tests - configuring errors' } +{ #category : 'tests - configuring errors' } RetryTest >> testOnWhenExpectedErrorIsRaisedAndSeveralErrorsHandled [ | count | @@ -372,7 +374,7 @@ RetryTest >> testOnWhenExpectedErrorIsRaisedAndSeveralErrorsHandled [ self assert: count equals: 4 ] -{ #category : #'tests - configuring errors' } +{ #category : 'tests - configuring errors' } RetryTest >> testOnWhenUnexpectedErrorIsRaised [ | count | @@ -397,7 +399,7 @@ RetryTest >> testOnWhenUnexpectedErrorIsRaised [ self assert: count equals: 1 ] -{ #category : #tests } +{ #category : 'tests' } RetryTest >> testRetryOnce [ | count | @@ -412,7 +414,7 @@ RetryTest >> testRetryOnce [ self assert: count equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } RetryTest >> testReturnValue [ | count result | @@ -428,7 +430,7 @@ RetryTest >> testReturnValue [ self assert: result equals: 2 ] -{ #category : #tests } +{ #category : 'tests' } RetryTest >> testReturnValueWhenNotRetrying [ | count result | @@ -443,7 +445,7 @@ RetryTest >> testReturnValueWhenNotRetrying [ self assert: result equals: 1 ] -{ #category : #'tests - configuring retry count' } +{ #category : 'tests - configuring retry count' } RetryTest >> testUpTo [ | count | @@ -466,7 +468,7 @@ RetryTest >> testUpTo [ self assert: count equals: 2 ] -{ #category : #'tests - configuring wait time' } +{ #category : 'tests - configuring wait time' } RetryTest >> testUpToTimesEvery [ | count runtime | @@ -493,7 +495,7 @@ RetryTest >> testUpToTimesEvery [ assert: runtime milliSeconds >= 300 milliSeconds ] -{ #category : #'tests - configuring condition' } +{ #category : 'tests - configuring condition' } RetryTest >> testWhen [ | count | @@ -514,7 +516,7 @@ RetryTest >> testWhen [ self assert: count equals: 4 ] -{ #category : #'tests - configuring condition' } +{ #category : 'tests - configuring condition' } RetryTest >> testWhenConditionNotUsed [ | count | @@ -535,7 +537,7 @@ RetryTest >> testWhenConditionNotUsed [ self assert: count equals: 1 ] -{ #category : #private } +{ #category : 'private' } RetryTest >> unexpectedError [ ^ HTTPServerError diff --git a/source/Hyperspace-Model-Tests/SafeCURIETest.class.st b/source/Hyperspace-Model-Tests/SafeCURIETest.class.st new file mode 100644 index 0000000..6322ff4 --- /dev/null +++ b/source/Hyperspace-Model-Tests/SafeCURIETest.class.st @@ -0,0 +1,82 @@ +" +A SafeCURIETest is a test class for testing the behavior of SafeCURIE +" +Class { + #name : 'SafeCURIETest', + #superclass : 'AbstractCURIETest', + #category : 'Hyperspace-Model-Tests', + #package : 'Hyperspace-Model-Tests' +} + +{ #category : 'private' } +SafeCURIETest >> curieClass [ + + ^ SafeCURIE +] + +{ #category : 'tests' } +SafeCURIETest >> testAsSafeCURIE [ + + | curie | + curie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + + self assert: curie asSafeCURIE equals: curie +] + +{ #category : 'tests' } +SafeCURIETest >> testFromString [ + + | curie | + curie := self curieClass fromString: '[users:octocat/tokens]'. + + self + assert: curie prefix equals: 'users'; + assertUrl: curie relativeReference equals: 'octocat' asUrl / 'tokens' +] + +{ #category : 'tests' } +SafeCURIETest >> testParsingErrors [ + + self + should: [ self curieClass fromString: '[:]' ] + raise: InstanceCreationFailed + withMessageText: 'A CURIE prefix cannot be empty'; + should: [ self curieClass fromString: '' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a Safe CURIE from ""'; + should: [ self curieClass fromString: '[' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a Safe CURIE from "["'; + should: [ self curieClass fromString: ']' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a Safe CURIE from "]"'; + should: [ self curieClass fromString: '[]' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a Safe CURIE from "[]"'; + should: [ self curieClass fromString: '[users:octocat:AAA]' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a CURIE from "users:octocat:AAA"'; + should: [ self curieClass fromString: '[users]' ] + raise: InstanceCreationFailed + withMessageText: 'Cannot create a CURIE from "users"' +] + +{ #category : 'tests' } +SafeCURIETest >> testPrinting [ + + | curie curieWithPath curieWithFragment | + + self assert: ( self curieClass fromString: '[users:]' ) printString equals: '[users:]'. + + curie := self curieClass prefixedBy: 'users' referencing: 'octocat' asUrl. + + self assert: curie printString equals: '[users:octocat]'. + + curieWithPath := curie / 'addresses'. + + self assert: curieWithPath printString equals: '[users:octocat/addresses]'. + + curieWithFragment := curieWithPath withFragment: 'primary'. + + self assert: curieWithFragment printString equals: '[users:octocat/addresses#primary]' +] diff --git a/source/Hyperspace-Model-Tests/WebLinkTest.class.st b/source/Hyperspace-Model-Tests/WebLinkTest.class.st index 5493707..e25e66d 100644 --- a/source/Hyperspace-Model-Tests/WebLinkTest.class.st +++ b/source/Hyperspace-Model-Tests/WebLinkTest.class.st @@ -2,12 +2,14 @@ I'm a test case for WebLink " Class { - #name : #WebLinkTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-IETF' + #name : 'WebLinkTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-IETF', + #package : 'Hyperspace-Model-Tests', + #tag : 'IETF' } -{ #category : #private } +{ #category : 'private' } WebLinkTest >> checkCollectionLinkRelationsOn: link [ self @@ -15,7 +17,7 @@ WebLinkTest >> checkCollectionLinkRelationsOn: link [ assert: link toCollection relationType equals: 'collection' ] -{ #category : #private } +{ #category : 'private' } WebLinkTest >> checkLegalLinkRelationsOn: link [ self @@ -24,7 +26,7 @@ WebLinkTest >> checkLegalLinkRelationsOn: link [ assert: link toCopyright relationType equals: 'copyright' ] -{ #category : #private } +{ #category : 'private' } WebLinkTest >> checkNavigationLinkRelationsOn: link [ self @@ -35,7 +37,7 @@ WebLinkTest >> checkNavigationLinkRelationsOn: link [ assert: link toParent relationType equals: 'up' ] -{ #category : #private } +{ #category : 'private' } WebLinkTest >> checkVersionNavigationLinkRelationsOn: link [ "Version Navigation Link Relations. See RFC 5829" @@ -49,13 +51,13 @@ WebLinkTest >> checkVersionNavigationLinkRelationsOn: link [ assert: link toWorkingCopyOrigin relationType equals: 'working-copy-of' ] -{ #category : #private } +{ #category : 'private' } WebLinkTest >> googleUrl [ ^ 'https://google.com' asUrl ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testAccessing [ | link | @@ -81,7 +83,7 @@ WebLinkTest >> testAccessing [ ';rel=search;title=Google Search;hreflang=en;type=text/html;media=screen' ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testAsByteArray [ self @@ -90,7 +92,7 @@ WebLinkTest >> testAsByteArray [ equals: ';rel=search' asByteArray ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testComparing [ | googleLink other | @@ -107,7 +109,7 @@ WebLinkTest >> testComparing [ self deny: googleLink equals: other ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testComplexMediaTypeHint [ | link mediaType | @@ -123,7 +125,7 @@ WebLinkTest >> testComplexMediaTypeHint [ equals: ';type="application/vnd.stargate.pet+json;version=2.0.0"' ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testCopying [ | googleLink copy | @@ -141,7 +143,36 @@ WebLinkTest >> testCopying [ assert: copy hasParameters ] -{ #category : #tests } +{ #category : 'tests' } +WebLinkTest >> testExtensionRelationTypes [ + "Extension relation types can be URIs or CURIEs. + See https://datatracker.ietf.org/doc/html/rfc5988#section-4.2" + + | link urlRelationType curieRelationType | + link := self googleUrl asWebLink. + + urlRelationType := 'https://api.example.com/docs/link-relations#create-person' asUrl. + + link relationType: urlRelationType. + + self + assert: link relationType equals: urlRelationType printString; + assert: link printString + equals: ';rel=https://api.example.com/docs/link-relations#create-person'. + + curieRelationType := SafeCURIE + prefixedBy: 'docs' + referencing: 'link-relations#create-person' asUrl. + + link relationType: curieRelationType. + + self + assert: link relationType equals: curieRelationType printString; + assert: link printString + equals: ';rel=[docs:link-relations#create-person]' +] + +{ #category : 'tests' } WebLinkTest >> testFromString [ | link parsedLink | @@ -156,7 +187,7 @@ WebLinkTest >> testFromString [ self assert: link equals: parsedLink ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testLanguageHints [ | link | @@ -168,7 +199,7 @@ WebLinkTest >> testLanguageHints [ self assert: link printString equals: ';hreflang=en-US;hreflang=es-AR' ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testMediaQueryHint [ | link | @@ -180,7 +211,7 @@ WebLinkTest >> testMediaQueryHint [ self assert: link printString equals: ';media="screen, print"' ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testMediaTypeHint [ | link | @@ -191,7 +222,7 @@ WebLinkTest >> testMediaTypeHint [ self assert: link printString equals: ';type=application/json' ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testParameters [ | link | @@ -208,7 +239,7 @@ WebLinkTest >> testParameters [ self assert: ( link parameterAt: 'foo' ifAbsent: [ #none ] ) equals: #none ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testParsingComplexLink [ | link | @@ -226,7 +257,7 @@ WebLinkTest >> testParsingComplexLink [ self assert: link printString asWebLink equals: link ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testParsingErrors [ self @@ -257,7 +288,7 @@ WebLinkTest >> testParsingErrors [ withMessageText: 'Invalid parameter format.' ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testPrinting [ self @@ -267,7 +298,7 @@ WebLinkTest >> testPrinting [ equals: ';rel=search' ] -{ #category : #tests } +{ #category : 'tests' } WebLinkTest >> testWellKnownRelationTypes [ | link | diff --git a/source/Hyperspace-Model-Tests/ZnClientHyperspaceExtensionsTest.class.st b/source/Hyperspace-Model-Tests/ZnClientHyperspaceExtensionsTest.class.st index 4a41700..a763941 100644 --- a/source/Hyperspace-Model-Tests/ZnClientHyperspaceExtensionsTest.class.st +++ b/source/Hyperspace-Model-Tests/ZnClientHyperspaceExtensionsTest.class.st @@ -1,10 +1,12 @@ Class { - #name : #ZnClientHyperspaceExtensionsTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Zinc' + #name : 'ZnClientHyperspaceExtensionsTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Zinc', + #package : 'Hyperspace-Model-Tests', + #tag : 'Zinc' } -{ #category : #private } +{ #category : 'private' } ZnClientHyperspaceExtensionsTest >> handleRequest: request [ self @@ -13,7 +15,7 @@ ZnClientHyperspaceExtensionsTest >> handleRequest: request [ ^ ZnResponse ok: (ZnEntity text: 'hello') ] -{ #category : #tests } +{ #category : 'tests' } ZnClientHyperspaceExtensionsTest >> testQuery [ | server port | @@ -34,7 +36,7 @@ ZnClientHyperspaceExtensionsTest >> testQuery [ ] ensure: [ server stop ] ] -{ #category : #tests } +{ #category : 'tests' } ZnClientHyperspaceExtensionsTest >> testResetRequest [ | client | @@ -47,7 +49,7 @@ ZnClientHyperspaceExtensionsTest >> testResetRequest [ self assert: client request url isNil ] -{ #category : #tests } +{ #category : 'tests' } ZnClientHyperspaceExtensionsTest >> testSetAccept [ | client | @@ -59,7 +61,7 @@ ZnClientHyperspaceExtensionsTest >> testSetAccept [ self assert: client request accept equals: ZnMimeType applicationPdf asString ] -{ #category : #tests } +{ #category : 'tests' } ZnClientHyperspaceExtensionsTest >> testSetIfMatchTo [ | client | @@ -71,7 +73,7 @@ ZnClientHyperspaceExtensionsTest >> testSetIfMatchTo [ self assert: ( client request headers at: 'If-Match' ) equals: '"12345"' ] -{ #category : #tests } +{ #category : 'tests' } ZnClientHyperspaceExtensionsTest >> testSetIfNoneMatchTo [ | client | @@ -83,7 +85,7 @@ ZnClientHyperspaceExtensionsTest >> testSetIfNoneMatchTo [ self assert: ( client request headers at: 'If-None-Match' ) equals: '"12345"' ] -{ #category : #tests } +{ #category : 'tests' } ZnClientHyperspaceExtensionsTest >> testSetLogLevelAtLeastTo [ | client | diff --git a/source/Hyperspace-Model-Tests/ZnEntityHyperspaceExtensionsTest.class.st b/source/Hyperspace-Model-Tests/ZnEntityHyperspaceExtensionsTest.class.st index ebd2443..80dba00 100644 --- a/source/Hyperspace-Model-Tests/ZnEntityHyperspaceExtensionsTest.class.st +++ b/source/Hyperspace-Model-Tests/ZnEntityHyperspaceExtensionsTest.class.st @@ -2,18 +2,20 @@ I'm a test case for Hyperspace's ZnEntity extensions " Class { - #name : #ZnEntityHyperspaceExtensionsTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Zinc' + #name : 'ZnEntityHyperspaceExtensionsTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Zinc', + #package : 'Hyperspace-Model-Tests', + #tag : 'Zinc' } -{ #category : #tests } +{ #category : 'tests' } ZnEntityHyperspaceExtensionsTest >> applicationJson [ ^ 'application/json' asMediaType ] -{ #category : #tests } +{ #category : 'tests' } ZnEntityHyperspaceExtensionsTest >> testJsonExtension [ | entity | @@ -24,7 +26,7 @@ ZnEntityHyperspaceExtensionsTest >> testJsonExtension [ assert: entity contentType equals: self applicationJson ] -{ #category : #tests } +{ #category : 'tests' } ZnEntityHyperspaceExtensionsTest >> testWithOfTypeExtension [ | entity | diff --git a/source/Hyperspace-Model-Tests/ZnMimeTypeHyperspaceExtensionsTest.class.st b/source/Hyperspace-Model-Tests/ZnMimeTypeHyperspaceExtensionsTest.class.st index 34723b3..2e6f578 100644 --- a/source/Hyperspace-Model-Tests/ZnMimeTypeHyperspaceExtensionsTest.class.st +++ b/source/Hyperspace-Model-Tests/ZnMimeTypeHyperspaceExtensionsTest.class.st @@ -1,10 +1,12 @@ Class { - #name : #ZnMimeTypeHyperspaceExtensionsTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Zinc' + #name : 'ZnMimeTypeHyperspaceExtensionsTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Zinc', + #package : 'Hyperspace-Model-Tests', + #tag : 'Zinc' } -{ #category : #tests } +{ #category : 'tests' } ZnMimeTypeHyperspaceExtensionsTest >> testComparingWithParameters [ | mimeType equalMimeType | diff --git a/source/Hyperspace-Model-Tests/ZnRequestHyperspaceExtensionsTest.class.st b/source/Hyperspace-Model-Tests/ZnRequestHyperspaceExtensionsTest.class.st index 4e0c99b..dd202b0 100644 --- a/source/Hyperspace-Model-Tests/ZnRequestHyperspaceExtensionsTest.class.st +++ b/source/Hyperspace-Model-Tests/ZnRequestHyperspaceExtensionsTest.class.st @@ -1,16 +1,18 @@ Class { - #name : #ZnRequestHyperspaceExtensionsTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Zinc' + #name : 'ZnRequestHyperspaceExtensionsTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Zinc', + #package : 'Hyperspace-Model-Tests', + #tag : 'Zinc' } -{ #category : #private } +{ #category : 'private' } ZnRequestHyperspaceExtensionsTest >> googleUrl [ ^ 'https://google.com' asUrl ] -{ #category : #tests } +{ #category : 'tests' } ZnRequestHyperspaceExtensionsTest >> testAcceptLanguage [ | request | @@ -24,7 +26,7 @@ ZnRequestHyperspaceExtensionsTest >> testAcceptLanguage [ self should: [ ( ZnRequest get: self googleUrl ) acceptLanguage ] raise: KeyNotFound ] -{ #category : #tests } +{ #category : 'tests' } ZnRequestHyperspaceExtensionsTest >> testHasLanguageProrityList [ | request | @@ -38,7 +40,7 @@ ZnRequestHyperspaceExtensionsTest >> testHasLanguageProrityList [ deny: ( ZnRequest get: self googleUrl ) hasLanguageProrityList ] -{ #category : #tests } +{ #category : 'tests' } ZnRequestHyperspaceExtensionsTest >> testIfMatch [ | request | @@ -50,7 +52,7 @@ ZnRequestHyperspaceExtensionsTest >> testIfMatch [ self assert: ( request headers at: 'If-Match' ) equals: '"12345"' ] -{ #category : #tests } +{ #category : 'tests' } ZnRequestHyperspaceExtensionsTest >> testIfNoneMatch [ | request | @@ -62,7 +64,7 @@ ZnRequestHyperspaceExtensionsTest >> testIfNoneMatch [ self assert: (request headers at: 'If-None-Match') equals: '"12345"' ] -{ #category : #tests } +{ #category : 'tests' } ZnRequestHyperspaceExtensionsTest >> testQuery [ | request output | @@ -76,7 +78,7 @@ ZnRequestHyperspaceExtensionsTest >> testQuery [ assert: (output includesSubstring: 'Host: google.com') ] -{ #category : #tests } +{ #category : 'tests' } ZnRequestHyperspaceExtensionsTest >> testReadQueryRequest [ | request | @@ -90,7 +92,7 @@ ZnRequestHyperspaceExtensionsTest >> testReadQueryRequest [ assertUrl: request host equals: 'http://google.com' ] -{ #category : #tests } +{ #category : 'tests' } ZnRequestHyperspaceExtensionsTest >> testSetAcceptLanguageWithAny [ | request | @@ -102,7 +104,7 @@ ZnRequestHyperspaceExtensionsTest >> testSetAcceptLanguageWithAny [ self assert: request acceptLanguage equals: '*' ] -{ #category : #tests } +{ #category : 'tests' } ZnRequestHyperspaceExtensionsTest >> testSetAcceptLanguageWithLanguageTag [ | request | diff --git a/source/Hyperspace-Model-Tests/ZnResponseHyperspaceExtensionsTest.class.st b/source/Hyperspace-Model-Tests/ZnResponseHyperspaceExtensionsTest.class.st index b1c7d26..2321f28 100644 --- a/source/Hyperspace-Model-Tests/ZnResponseHyperspaceExtensionsTest.class.st +++ b/source/Hyperspace-Model-Tests/ZnResponseHyperspaceExtensionsTest.class.st @@ -1,29 +1,31 @@ Class { - #name : #ZnResponseHyperspaceExtensionsTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Zinc' + #name : 'ZnResponseHyperspaceExtensionsTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Zinc', + #package : 'Hyperspace-Model-Tests', + #tag : 'Zinc' } -{ #category : #private } +{ #category : 'private' } ZnResponseHyperspaceExtensionsTest >> amazonUrl [ ^ 'https://amazon.com' asUrl ] -{ #category : #private } +{ #category : 'private' } ZnResponseHyperspaceExtensionsTest >> encodeAndDecode: response [ ^ ZnResponse readFrom: ( ByteArray streamContents: [ :stream | response writeOn: stream ] ) readStream ] -{ #category : #private } +{ #category : 'private' } ZnResponseHyperspaceExtensionsTest >> googleUrl [ ^ 'https://google.com' asUrl ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testAddContentLanguageTags [ | response | @@ -40,7 +42,7 @@ ZnResponseHyperspaceExtensionsTest >> testAddContentLanguageTags [ ( LanguageTag fromString: 'es-AR' )} ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testAddSeveralLinks [ | response | @@ -57,7 +59,7 @@ ZnResponseHyperspaceExtensionsTest >> testAddSeveralLinks [ WebLink to: self amazonUrl } ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testCachingDirectives [ | response | @@ -71,7 +73,7 @@ ZnResponseHyperspaceExtensionsTest >> testCachingDirectives [ self assert: response cachingDirectives equals: #('public' 'Max-Age=60') ] -{ #category : #'tests - encoding' } +{ #category : 'tests - encoding' } ZnResponseHyperspaceExtensionsTest >> testEncodeAndDecodeWithContentLanguageHeaders [ | response decodedResponse | @@ -86,7 +88,7 @@ ZnResponseHyperspaceExtensionsTest >> testEncodeAndDecodeWithContentLanguageHead self assert: decodedResponse contentLanguageTags equals: response contentLanguageTags ] -{ #category : #'tests - encoding' } +{ #category : 'tests - encoding' } ZnResponseHyperspaceExtensionsTest >> testEncodeAndDecodeWithEntityTag [ | response entityTag decodedResponse | @@ -102,7 +104,7 @@ ZnResponseHyperspaceExtensionsTest >> testEncodeAndDecodeWithEntityTag [ ifAbsent: [ self fail ] ] -{ #category : #'tests - encoding' } +{ #category : 'tests - encoding' } ZnResponseHyperspaceExtensionsTest >> testEncodeAndDecodeWithLinkHeaders [ | response decodedResponse | @@ -116,7 +118,7 @@ ZnResponseHyperspaceExtensionsTest >> testEncodeAndDecodeWithLinkHeaders [ self assert: decodedResponse links equals: response links ] -{ #category : #'tests - encoding' } +{ #category : 'tests - encoding' } ZnResponseHyperspaceExtensionsTest >> testEncodeAndDecodeWithVaryHeaders [ | response decodedResponse | @@ -131,7 +133,7 @@ ZnResponseHyperspaceExtensionsTest >> testEncodeAndDecodeWithVaryHeaders [ self assert: decodedResponse varyHeaderNames equals: response varyHeaderNames ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testEntityTag [ | response entityTag | @@ -147,7 +149,7 @@ ZnResponseHyperspaceExtensionsTest >> testEntityTag [ self should: [ ZnResponse noContent entityTag ] raise: KeyNotFound ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testHasLocation [ self @@ -155,7 +157,7 @@ ZnResponseHyperspaceExtensionsTest >> testHasLocation [ assert: ( ZnResponse created: 'https://api.example.com/123' ) hasLocation ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testLink [ | response | @@ -167,7 +169,7 @@ ZnResponseHyperspaceExtensionsTest >> testLink [ self assert: response links equals: { WebLink to: self googleUrl } ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testVary [ | response | @@ -186,7 +188,7 @@ ZnResponseHyperspaceExtensionsTest >> testVary [ self assert: response varyHeaderNames equals: #('Accept' 'Accept-Language') ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testWithEntityTagDo [ | response entityTag wasFound | @@ -207,7 +209,7 @@ ZnResponseHyperspaceExtensionsTest >> testWithEntityTagDo [ self assert: wasFound ] -{ #category : #tests } +{ #category : 'tests' } ZnResponseHyperspaceExtensionsTest >> testWithEntityTagDoNotFound [ | response headerWasNotFound | diff --git a/source/Hyperspace-Model-Tests/ZnServerHyperspaceExtensionsTest.class.st b/source/Hyperspace-Model-Tests/ZnServerHyperspaceExtensionsTest.class.st index 4aef672..dda0a8e 100644 --- a/source/Hyperspace-Model-Tests/ZnServerHyperspaceExtensionsTest.class.st +++ b/source/Hyperspace-Model-Tests/ZnServerHyperspaceExtensionsTest.class.st @@ -1,10 +1,12 @@ Class { - #name : #ZnServerHyperspaceExtensionsTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Zinc' + #name : 'ZnServerHyperspaceExtensionsTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Zinc', + #package : 'Hyperspace-Model-Tests', + #tag : 'Zinc' } -{ #category : #tests } +{ #category : 'tests' } ZnServerHyperspaceExtensionsTest >> testSetLogLevelAtLeastTo [ | server | diff --git a/source/Hyperspace-Model-Tests/ZnUrlHyperspaceExtensionsTest.class.st b/source/Hyperspace-Model-Tests/ZnUrlHyperspaceExtensionsTest.class.st index 870d3bd..d24a50d 100644 --- a/source/Hyperspace-Model-Tests/ZnUrlHyperspaceExtensionsTest.class.st +++ b/source/Hyperspace-Model-Tests/ZnUrlHyperspaceExtensionsTest.class.st @@ -2,12 +2,14 @@ I'm a test for extensions on ZnUrl " Class { - #name : #ZnUrlHyperspaceExtensionsTest, - #superclass : #TestCase, - #category : #'Hyperspace-Model-Tests-Zinc' + #name : 'ZnUrlHyperspaceExtensionsTest', + #superclass : 'TestCase', + #category : 'Hyperspace-Model-Tests-Zinc', + #package : 'Hyperspace-Model-Tests', + #tag : 'Zinc' } -{ #category : #tests } +{ #category : 'tests' } ZnUrlHyperspaceExtensionsTest >> testAsAbsoluteUrl [ self @@ -26,7 +28,7 @@ ZnUrlHyperspaceExtensionsTest >> testAsAbsoluteUrl [ withMessageText: '/resource is a relative URL' ] -{ #category : #tests } +{ #category : 'tests' } ZnUrlHyperspaceExtensionsTest >> testAsHostedAt [ self @@ -44,7 +46,7 @@ ZnUrlHyperspaceExtensionsTest >> testAsHostedAt [ equals: 'https://alternative.org:2222/resource' asUrl ] -{ #category : #tests } +{ #category : 'tests' } ZnUrlHyperspaceExtensionsTest >> testAsWebLink [ | url | @@ -53,7 +55,7 @@ ZnUrlHyperspaceExtensionsTest >> testAsWebLink [ self assert: url asWebLink equals: ( WebLink to: url ) ] -{ #category : #tests } +{ #category : 'tests' } ZnUrlHyperspaceExtensionsTest >> testQueryAtPutUrl [ self @@ -64,7 +66,7 @@ ZnUrlHyperspaceExtensionsTest >> testQueryAtPutUrl [ equals: 'https://api.example.com/pets?relatedTo=https%253A%252F%252Fapi.example.com%252Fpets%252F99' asUrl ] -{ #category : #tests } +{ #category : 'tests' } ZnUrlHyperspaceExtensionsTest >> testStartLimit [ self diff --git a/source/Hyperspace-Model-Tests/package.st b/source/Hyperspace-Model-Tests/package.st index 27f250f..7e4145e 100644 --- a/source/Hyperspace-Model-Tests/package.st +++ b/source/Hyperspace-Model-Tests/package.st @@ -1 +1 @@ -Package { #name : #'Hyperspace-Model-Tests' } +Package { #name : 'Hyperspace-Model-Tests' } diff --git a/source/Hyperspace-Model/AbstractCURIE.class.st b/source/Hyperspace-Model/AbstractCURIE.class.st new file mode 100644 index 0000000..2126f74 --- /dev/null +++ b/source/Hyperspace-Model/AbstractCURIE.class.st @@ -0,0 +1,74 @@ +Class { + #name : 'AbstractCURIE', + #superclass : 'Object', + #category : 'Hyperspace-Model', + #package : 'Hyperspace-Model' +} + +{ #category : 'instance creation' } +AbstractCURIE class >> fromString: string [ + + ^ self subclassResponsibility +] + +{ #category : 'testing' } +AbstractCURIE class >> isAbstract [ + + ^ self = AbstractCURIE +] + +{ #category : 'instance creation' } +AbstractCURIE class >> prefixedBy: aPrefix referencing: aRelativeUrl [ + + ^ self subclassResponsibility +] + +{ #category : 'converting' } +AbstractCURIE >> / object [ + + ^ self class prefixedBy: self prefix referencing: self relativeReference / object +] + +{ #category : 'converting' } +AbstractCURIE >> asSafeCURIE [ + + ^ self subclassResponsibility +] + +{ #category : 'converting' } +AbstractCURIE >> asWebLink [ + + ^ WebLink to: self +] + +{ #category : 'converting' } +AbstractCURIE >> expandToURIIn: context [ + + | base | + base := context + at: self prefix + ifAbsent: [ + ObjectNotFound signal: ( 'Missing namespace "<1s>"' expandMacrosWith: self prefix ) ]. + + ^ base / self relativeReference expandToURIIn: context +] + +{ #category : 'accessing' } +AbstractCURIE >> prefix [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +AbstractCURIE >> relativeReference [ + + ^ self subclassResponsibility +] + +{ #category : 'converting' } +AbstractCURIE >> withFragment: fragment [ + + ^ self class + prefixedBy: self prefix + referencing: ( self relativeReference withFragment: fragment ) +] diff --git a/source/Hyperspace-Model/CURIE.class.st b/source/Hyperspace-Model/CURIE.class.st new file mode 100644 index 0000000..a530a4c --- /dev/null +++ b/source/Hyperspace-Model/CURIE.class.st @@ -0,0 +1,101 @@ +" +A CURIE is a compact syntax for URIs. + +Normative Reference: +- https://www.w3.org/TR/curie/ +" +Class { + #name : 'CURIE', + #superclass : 'AbstractCURIE', + #instVars : [ + 'prefix', + 'relativeReference' + ], + #category : 'Hyperspace-Model', + #package : 'Hyperspace-Model' +} + +{ #category : 'instance creation' } +CURIE class >> fromString: string [ + + | segments | + segments := string splitOn: $:. + AssertionChecker + enforce: [ segments size = 2 ] + because: [ 'Cannot create a CURIE from "<1s>"' expandMacrosWith: string ] + raising: InstanceCreationFailed. + ^ self prefixedBy: segments first referencing: segments second asUrl +] + +{ #category : 'instance creation' } +CURIE class >> prefixedBy: aPrefix referencing: aRelativeUrl [ + + AssertionChecker + check: [ :asserter | + asserter + enforce: [ aRelativeUrl isRelative ] + because: [ '<1p> must be a relative reference' expandMacrosWith: aRelativeUrl ]; + enforce: [ aPrefix notEmpty ] because: 'A CURIE prefix cannot be empty' + ] + configuredBy: [ :checker | checker raising: InstanceCreationFailed ]. + + ^ self new initializePrefixedBy: aPrefix referencing: aRelativeUrl +] + +{ #category : 'comparing' } +CURIE >> = object [ + + ^ self equalityChecker + compare: #prefix; + compare: #relativeReference; + checkAgainst: object +] + +{ #category : 'converting' } +CURIE >> asSafeCURIE [ + + ^ SafeCURIE from: self +] + +{ #category : 'comparing' } +CURIE >> hash [ + + ^ self equalityHashCombinator combineHashOf: prefix with: relativeReference +] + +{ #category : 'initialization' } +CURIE >> initializePrefixedBy: aPrefix referencing: aRelativeUrl [ + + prefix := aPrefix. + relativeReference := aRelativeUrl +] + +{ #category : 'accessing' } +CURIE >> prefix [ + + ^ prefix +] + +{ #category : 'printing' } +CURIE >> printOn: stream [ + + stream + nextPutAll: prefix; + nextPut: $:. + relativeReference hasPath then: [ + relativeReference segments + do: [ :segment | relativeReference encodePath: segment on: stream ] + separatedBy: [ stream nextPut: $/ ] + ]. + relativeReference hasQuery then: [ relativeReference printQueryOn: stream ]. + relativeReference hasFragment then: [ + stream nextPut: $#. + relativeReference encodeFragment: relativeReference fragment on: stream + ] +] + +{ #category : 'accessing' } +CURIE >> relativeReference [ + + ^ relativeReference +] diff --git a/source/Hyperspace-Model/EntityTag.class.st b/source/Hyperspace-Model/EntityTag.class.st index 6e53e9f..8b0ba0d 100644 --- a/source/Hyperspace-Model/EntityTag.class.st +++ b/source/Hyperspace-Model/EntityTag.class.st @@ -9,16 +9,18 @@ References: - [RFC 7232](https://datatracker.ietf.org/doc/html/rfc7232#section-2.3) " Class { - #name : #EntityTag, - #superclass : #Object, + #name : 'EntityTag', + #superclass : 'Object', #instVars : [ 'value', 'suffix' ], - #category : #'Hyperspace-Model-IETF' + #category : 'Hyperspace-Model-IETF', + #package : 'Hyperspace-Model', + #tag : 'IETF' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } EntityTag class >> fromString: aString [ AssertionCheckerBuilder new @@ -35,7 +37,7 @@ EntityTag class >> fromString: aString [ inWhichCase: [ self parseWeakETagFromString: aString ] ] -{ #category : #'private - instance creation' } +{ #category : 'private - instance creation' } EntityTag class >> parseStrongETagFromString: aString [ AssertionCheckerBuilder new @@ -52,7 +54,7 @@ EntityTag class >> parseStrongETagFromString: aString [ ^ self with: (aString copyFrom: 2 to: aString size - 1) ] -{ #category : #'private - instance creation' } +{ #category : 'private - instance creation' } EntityTag class >> parseWeakETagFromString: aString [ AssertionCheckerBuilder new @@ -69,25 +71,25 @@ EntityTag class >> parseWeakETagFromString: aString [ ^ self weakWith: (aString copyFrom: 4 to: aString size - 1) ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } EntityTag class >> weakWith: anETagValue [ ^ self with: anETagValue suffixedBy: 'W/' ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } EntityTag class >> with: anETagValue [ ^ self with: anETagValue suffixedBy: '' ] -{ #category : #'private - instance creation' } +{ #category : 'private - instance creation' } EntityTag class >> with: anETagValue suffixedBy: aSuffix [ ^ self new initializeWith: anETagValue suffixedBy: aSuffix ] -{ #category : #comparing } +{ #category : 'comparing' } EntityTag >> = anObject [ ^ self equalityChecker @@ -95,32 +97,32 @@ EntityTag >> = anObject [ checkAgainst: anObject ] -{ #category : #converting } +{ #category : 'converting' } EntityTag >> asEntityTag [ ^ self ] -{ #category : #printing } +{ #category : 'printing' } EntityTag >> asString [ ^self printString ] -{ #category : #comparing } +{ #category : 'comparing' } EntityTag >> hash [ ^ value hash ] -{ #category : #initialization } +{ #category : 'initialization' } EntityTag >> initializeWith: anETagValue suffixedBy: aSuffix [ value := anETagValue. suffix := aSuffix ] -{ #category : #printing } +{ #category : 'printing' } EntityTag >> printOn: aStream [ aStream @@ -130,7 +132,7 @@ EntityTag >> printOn: aStream [ nextPut: $" ] -{ #category : #evaluating } +{ #category : 'evaluating' } EntityTag >> value [ ^ value diff --git a/source/Hyperspace-Model/ExceptionSelectorSet.class.st b/source/Hyperspace-Model/ExceptionSelectorSet.class.st index 2252819..1741620 100644 --- a/source/Hyperspace-Model/ExceptionSelectorSet.class.st +++ b/source/Hyperspace-Model/ExceptionSelectorSet.class.st @@ -1,27 +1,29 @@ Class { - #name : #ExceptionSelectorSet, - #superclass : #Object, + #name : 'ExceptionSelectorSet', + #superclass : 'Object', #instVars : [ 'value', 'suffix', 'selectors' ], - #category : #'Hyperspace-Model-IETF' + #category : 'Hyperspace-Model-IETF', + #package : 'Hyperspace-Model', + #tag : 'IETF' } -{ #category : #'exception selector' } +{ #category : 'exception selector' } ExceptionSelectorSet >> , exceptionSelector [ selectors add: exceptionSelector ] -{ #category : #'exception selector' } +{ #category : 'exception selector' } ExceptionSelectorSet >> handles: anException [ ^ selectors anySatisfy: [ :selector | selector handles: anException ] ] -{ #category : #initialization } +{ #category : 'initialization' } ExceptionSelectorSet >> initialize [ super initialize. diff --git a/source/Hyperspace-Model/HTTPClientError.class.st b/source/Hyperspace-Model/HTTPClientError.class.st index 084de0f..51e82ab 100644 --- a/source/Hyperspace-Model/HTTPClientError.class.st +++ b/source/Hyperspace-Model/HTTPClientError.class.st @@ -2,12 +2,14 @@ I represent an HTTP Client Error [ 4xx ] " Class { - #name : #HTTPClientError, - #superclass : #HTTPError, - #category : #'Hyperspace-Model-Exceptions' + #name : 'HTTPClientError', + #superclass : 'HTTPError', + #category : 'Hyperspace-Model-Exceptions', + #package : 'Hyperspace-Model', + #tag : 'Exceptions' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPClientError class >> badRequest [ "The server cannot or will not process the request due to something that is perceived to be a client error @@ -16,7 +18,7 @@ HTTPClientError class >> badRequest [ ^ self code: 400 ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPClientError class >> conflict [ "The request could not be completed due to a conflict with the current state of the target resource. @@ -26,7 +28,7 @@ HTTPClientError class >> conflict [ ^ self code: 409 ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPClientError class >> notFound [ "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. @@ -36,7 +38,7 @@ HTTPClientError class >> notFound [ ^ self code: 404 ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPClientError class >> preconditionFailed [ "One or more conditions given in the request header fields evaluated to false when tested on the server. @@ -46,7 +48,7 @@ HTTPClientError class >> preconditionFailed [ ^ self code: 412 ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPClientError class >> preconditionRequired [ "The origin server requires the request to be conditional. @@ -57,7 +59,7 @@ HTTPClientError class >> preconditionRequired [ ^ self code: 428 ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPClientError class >> tooManyRequests [ "The user has sent too many requests in a given amount of time (rate limiting). @@ -67,7 +69,7 @@ HTTPClientError class >> tooManyRequests [ ^ self code: 429 ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPClientError class >> unprocessableEntity [ "The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), @@ -77,7 +79,7 @@ HTTPClientError class >> unprocessableEntity [ ^ self code: 422 ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPClientError class >> unsupportedMediaType [ "The origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource. diff --git a/source/Hyperspace-Model/HTTPError.class.st b/source/Hyperspace-Model/HTTPError.class.st index ab05d06..ad613b1 100644 --- a/source/Hyperspace-Model/HTTPError.class.st +++ b/source/Hyperspace-Model/HTTPError.class.st @@ -2,15 +2,17 @@ I'm an exception expecting to be raised when there's an error processing an HTTP request. " Class { - #name : #HTTPError, - #superclass : #Error, + #name : 'HTTPError', + #superclass : 'Error', #instVars : [ 'code' ], - #category : #'Hyperspace-Model-Exceptions' + #category : 'Hyperspace-Model-Exceptions', + #package : 'Hyperspace-Model', + #tag : 'Exceptions' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPError class >> code: aCode [ | instance | @@ -20,31 +22,31 @@ HTTPError class >> code: aCode [ ^ instance ] -{ #category : #'exception selector' } +{ #category : 'exception selector' } HTTPError >> , exceptionSelector [ ^ ExceptionSelectorSet new , self , exceptionSelector ] -{ #category : #accessing } +{ #category : 'accessing' } HTTPError >> code [ ^ code ] -{ #category : #accessing } +{ #category : 'accessing' } HTTPError >> code: anErrorCode [ code := anErrorCode ] -{ #category : #'exception selector' } +{ #category : 'exception selector' } HTTPError >> handles: aSignal [ ^ ( self class handles: aSignal ) and: [ aSignal code = self code ] ] -{ #category : #printing } +{ #category : 'printing' } HTTPError >> printOn: stream [ stream diff --git a/source/Hyperspace-Model/HTTPNotAcceptable.class.st b/source/Hyperspace-Model/HTTPNotAcceptable.class.st index 6feb760..ff93543 100644 --- a/source/Hyperspace-Model/HTTPNotAcceptable.class.st +++ b/source/Hyperspace-Model/HTTPNotAcceptable.class.st @@ -12,16 +12,18 @@ Unless it was a HEAD request, the response SHOULD include an entity containing a If the response could be unacceptable, a user agent SHOULD temporarily stop receipt of more data and query the user for a decision on further actions. " Class { - #name : #HTTPNotAcceptable, - #superclass : #HTTPClientError, + #name : 'HTTPNotAcceptable', + #superclass : 'HTTPClientError', #instVars : [ 'allowedMediaTypes', 'allowedLanguageTags' ], - #category : #'Hyperspace-Model-Exceptions' + #category : 'Hyperspace-Model-Exceptions', + #package : 'Hyperspace-Model', + #tag : 'Exceptions' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPNotAcceptable class >> messageText: aMessageText accepting: allowedMediaTypes inAnyOf: allowedLanguageTags [ ^ ( self code: 406 ) @@ -31,37 +33,37 @@ HTTPNotAcceptable class >> messageText: aMessageText accepting: allowedMediaType yourself ] -{ #category : #signalling } +{ #category : 'signalling' } HTTPNotAcceptable class >> signal: aMessageText accepting: allowedMediaTypes [ ^ self signal: aMessageText accepting: allowedMediaTypes inAnyOf: #() ] -{ #category : #signalling } +{ #category : 'signalling' } HTTPNotAcceptable class >> signal: aMessageText accepting: allowedMediaTypes inAnyOf: allowedLanguageTags [ ^ ( self messageText: aMessageText accepting: allowedMediaTypes inAnyOf: allowedLanguageTags ) signal ] -{ #category : #accessing } +{ #category : 'accessing' } HTTPNotAcceptable >> allowedLanguageTags [ ^ allowedLanguageTags ] -{ #category : #accessing } +{ #category : 'accessing' } HTTPNotAcceptable >> allowedLanguageTags: anArray [ allowedLanguageTags := anArray ] -{ #category : #accessing } +{ #category : 'accessing' } HTTPNotAcceptable >> allowedMediaTypes [ ^ allowedMediaTypes ] -{ #category : #accessing } +{ #category : 'accessing' } HTTPNotAcceptable >> allowedMediaTypes: anArray [ allowedMediaTypes := anArray diff --git a/source/Hyperspace-Model/HTTPServerError.class.st b/source/Hyperspace-Model/HTTPServerError.class.st index 95118ef..2265bc3 100644 --- a/source/Hyperspace-Model/HTTPServerError.class.st +++ b/source/Hyperspace-Model/HTTPServerError.class.st @@ -11,24 +11,26 @@ The server is currently unable to handle the request due to a temporary overload The server MAY send a Retry-After header field1 to suggest an appropriate amount of time for the client to wait before retrying the request. " Class { - #name : #HTTPServerError, - #superclass : #HTTPError, - #category : #'Hyperspace-Model-Exceptions' + #name : 'HTTPServerError', + #superclass : 'HTTPError', + #category : 'Hyperspace-Model-Exceptions', + #package : 'Hyperspace-Model', + #tag : 'Exceptions' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPServerError class >> internalServerError [ ^ self code: 500 ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } HTTPServerError class >> serviceUnavailable [ ^ self code: 503 ] -{ #category : #signalling } +{ #category : 'signalling' } HTTPServerError class >> signalInternalServerError: aMessageText [ ^ self internalServerError signal: aMessageText diff --git a/source/Hyperspace-Model/LanguageRange.class.st b/source/Hyperspace-Model/LanguageRange.class.st index 59dac00..3b749c3 100644 --- a/source/Hyperspace-Model/LanguageRange.class.st +++ b/source/Hyperspace-Model/LanguageRange.class.st @@ -16,27 +16,29 @@ Reference: https://datatracker.ietf.org/doc/html/rfc3066 " Class { - #name : #LanguageRange, - #superclass : #Object, + #name : 'LanguageRange', + #superclass : 'Object', #instVars : [ 'languageTagOptional' ], - #category : #'Hyperspace-Model-IETF' + #category : 'Hyperspace-Model-IETF', + #package : 'Hyperspace-Model', + #tag : 'IETF' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } LanguageRange class >> any [ ^ self with: Optional unused ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } LanguageRange class >> from: aSubtagCollection [ ^ self with: ( Optional containing: ( LanguageTag from: aSubtagCollection ) ) ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } LanguageRange class >> fromString: aString [ ^ aString = '*' @@ -44,13 +46,13 @@ LanguageRange class >> fromString: aString [ otherwise: [ self with: ( Optional containing: ( LanguageTag fromString: aString ) ) ] ] -{ #category : #'private - instance creation' } +{ #category : 'private - instance creation' } LanguageRange class >> with: aLanguageTagOptional [ ^ self new initializeWith: aLanguageTagOptional ] -{ #category : #comparing } +{ #category : 'comparing' } LanguageRange >> = anObject [ ^ self equalityChecker @@ -58,25 +60,25 @@ LanguageRange >> = anObject [ checkAgainst: anObject ] -{ #category : #converting } +{ #category : 'converting' } LanguageRange >> asString [ ^ self printString ] -{ #category : #comparing } +{ #category : 'comparing' } LanguageRange >> hash [ ^ languageTagOptional withContentDo: [ :tag | tag hash ] ifUnused: [ $* hash ] ] -{ #category : #initialization } +{ #category : 'initialization' } LanguageRange >> initializeWith: aLanguageTagOptional [ languageTagOptional := aLanguageTagOptional ] -{ #category : #testing } +{ #category : 'testing' } LanguageRange >> matches: aLanguageTag [ ^ languageTagOptional @@ -84,13 +86,13 @@ LanguageRange >> matches: aLanguageTag [ ifUnused: [ true ] ] -{ #category : #printing } +{ #category : 'printing' } LanguageRange >> printOn: stream [ languageTagOptional withContentDo: [ :tag | tag printOn: stream ] ifUnused: [ stream nextPut: $* ] ] -{ #category : #accessing } +{ #category : 'accessing' } LanguageRange >> subtags [ ^ languageTagOptional withContentDo: [ :tag | tag subtags ] ifUnused: [ #('*') ] diff --git a/source/Hyperspace-Model/LanguageTag.class.st b/source/Hyperspace-Model/LanguageTag.class.st index d220a02..3c7d25d 100644 --- a/source/Hyperspace-Model/LanguageTag.class.st +++ b/source/Hyperspace-Model/LanguageTag.class.st @@ -14,18 +14,20 @@ Reference: " Class { - #name : #LanguageTag, - #superclass : #Object, + #name : 'LanguageTag', + #superclass : 'Object', #instVars : [ 'languageCode', 'scriptOptional', 'regionOptional', 'subtags' ], - #category : #'Hyperspace-Model-IETF' + #category : 'Hyperspace-Model-IETF', + #package : 'Hyperspace-Model', + #tag : 'IETF' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } LanguageTag class >> from: aSubtagCollection [ AssertionChecker @@ -36,13 +38,13 @@ LanguageTag class >> from: aSubtagCollection [ ^ self new initializeFrom: aSubtagCollection ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } LanguageTag class >> fromString: aString [ ^ self from: ( aString substrings: '-' ) ] -{ #category : #comparing } +{ #category : 'comparing' } LanguageTag >> = anObject [ ^ self equalityChecker @@ -50,25 +52,25 @@ LanguageTag >> = anObject [ checkAgainst: anObject ] -{ #category : #converting } +{ #category : 'converting' } LanguageTag >> asByteArray [ ^ self printString asByteArray ] -{ #category : #converting } +{ #category : 'converting' } LanguageTag >> asLanguageTag [ ^ self ] -{ #category : #printing } +{ #category : 'printing' } LanguageTag >> asString [ ^ self printString ] -{ #category : #private } +{ #category : 'private' } LanguageTag >> assertIsValid [ AssertionCheckerBuilder new @@ -96,13 +98,13 @@ LanguageTag >> assertIsValid [ buildAndCheck ] -{ #category : #comparing } +{ #category : 'comparing' } LanguageTag >> hash [ ^ self equalityHashCombinator combineHashesOfAll: subtags ] -{ #category : #initialization } +{ #category : 'initialization' } LanguageTag >> initializeFrom: aSubtagCollection [ subtags := Array withAll: aSubtagCollection. @@ -113,14 +115,14 @@ LanguageTag >> initializeFrom: aSubtagCollection [ assertIsValid ] -{ #category : #private } +{ #category : 'private' } LanguageTag >> initializeLanguageCode [ subtags at: 1 put: subtags first asLowercase. languageCode := subtags first ] -{ #category : #private } +{ #category : 'private' } LanguageTag >> initializeRegion [ regionOptional := Optional unused. @@ -129,7 +131,7 @@ LanguageTag >> initializeRegion [ ifUnused: [ self initializeRegionTaggedAt: 2 ] ] -{ #category : #private } +{ #category : 'private' } LanguageTag >> initializeRegionTaggedAt: index [ [ | regionCandidate | @@ -142,7 +144,7 @@ LanguageTag >> initializeRegionTaggedAt: index [ ] unless: subtags size < index ] -{ #category : #private } +{ #category : 'private' } LanguageTag >> initializeScript [ scriptOptional := Optional unused. @@ -157,31 +159,31 @@ LanguageTag >> initializeScript [ ] unless: subtags size = 1 ] -{ #category : #accessing } +{ #category : 'accessing' } LanguageTag >> languageCode [ ^ languageCode ] -{ #category : #printing } +{ #category : 'printing' } LanguageTag >> printOn: stream [ subtags do: [ :subtag | stream nextPutAll: subtag ] separatedBy: [ stream nextPut: $- ] ] -{ #category : #accessing } +{ #category : 'accessing' } LanguageTag >> subtags [ ^ subtags ] -{ #category : #accessing } +{ #category : 'accessing' } LanguageTag >> withRegionDo: aBlock [ regionOptional withContentDo: aBlock ] -{ #category : #accessing } +{ #category : 'accessing' } LanguageTag >> withScriptDo: aBlock [ scriptOptional withContentDo: aBlock diff --git a/source/Hyperspace-Model/MultiValueOrderedDictionary.class.st b/source/Hyperspace-Model/MultiValueOrderedDictionary.class.st index 073ff0b..cc9c723 100644 --- a/source/Hyperspace-Model/MultiValueOrderedDictionary.class.st +++ b/source/Hyperspace-Model/MultiValueOrderedDictionary.class.st @@ -3,12 +3,14 @@ I'm like ZnMultiValueDictionary but preserving the insertion order of my keys. I'm here to provide deterministic behavior to objects using me. " Class { - #name : #MultiValueOrderedDictionary, - #superclass : #OrderedDictionary, - #category : #'Hyperspace-Model-IETF' + #name : 'MultiValueOrderedDictionary', + #superclass : 'OrderedDictionary', + #category : 'Hyperspace-Model-IETF', + #package : 'Hyperspace-Model', + #tag : 'IETF' } -{ #category : #enumerating } +{ #category : 'enumerating' } MultiValueOrderedDictionary >> at: key add: value [ "Store value under key. If key already exists, store multiple values as Array" @@ -25,7 +27,7 @@ MultiValueOrderedDictionary >> at: key add: value [ ^ self at: key put: newValue ] -{ #category : #enumerating } +{ #category : 'enumerating' } MultiValueOrderedDictionary >> keysAndValuesDo: block [ "Execute a two argument (key, value) block for each header. Multi-valued headers are handled transparently." diff --git a/source/Hyperspace-Model/PortAvailabilityChecker.class.st b/source/Hyperspace-Model/PortAvailabilityChecker.class.st index 48c2b7b..f8288bf 100644 --- a/source/Hyperspace-Model/PortAvailabilityChecker.class.st +++ b/source/Hyperspace-Model/PortAvailabilityChecker.class.st @@ -3,22 +3,24 @@ I'm here to help to identify if some port is free or not, so we can start a serv Whenever possible, it is best to let the OS provide us a free port. But if you need to constraint the port selection, I'm useful in detecting available ports. " Class { - #name : #PortAvailabilityChecker, - #superclass : #Object, + #name : 'PortAvailabilityChecker', + #superclass : 'Object', #classInstVars : [ 'uniqueInstance' ], - #category : #'Hyperspace-Model-Resilience' + #category : 'Hyperspace-Model-Resilience', + #package : 'Hyperspace-Model', + #tag : 'Resilience' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } PortAvailabilityChecker class >> new [ uniqueInstance ifNil: [ uniqueInstance := super new ]. ^ uniqueInstance ] -{ #category : #conditional } +{ #category : 'conditional' } PortAvailabilityChecker >> if: portNumber isAvailableForTCP: aFoundBlock ifNot: aNotFoundBlock [ ^ ( self isAvailableForTCP: portNumber ) @@ -26,7 +28,7 @@ PortAvailabilityChecker >> if: portNumber isAvailableForTCP: aFoundBlock ifNot: ifFalse: [ aNotFoundBlock cull: ( 'Port <1p> is not available' expandMacrosWith: portNumber ) ] ] -{ #category : #testing } +{ #category : 'testing' } PortAvailabilityChecker >> isAvailableForTCP: portNumber [ ^ [ diff --git a/source/Hyperspace-Model/Retry.class.st b/source/Hyperspace-Model/Retry.class.st index 5658d3e..2385d8e 100644 --- a/source/Hyperspace-Model/Retry.class.st +++ b/source/Hyperspace-Model/Retry.class.st @@ -22,8 +22,8 @@ Retry " Class { - #name : #Retry, - #superclass : #Object, + #name : 'Retry', + #superclass : 'Object', #instVars : [ 'maximumNumberOfAttempts', 'waitActionBetweenRetries', @@ -33,40 +33,42 @@ Class { 'exceptionBasedActionBetweenRetries', 'exceptionToRetry' ], - #category : #'Hyperspace-Model-Resilience' + #category : 'Hyperspace-Model-Resilience', + #package : 'Hyperspace-Model', + #tag : 'Resilience' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } Retry class >> configuredBy: configurationAction [ ^ self new initializeConfiguredBy: configurationAction ] -{ #category : #accessing } +{ #category : 'accessing' } Retry class >> defaultMaximumNumberOfAttempts [ ^ 3 ] -{ #category : #evaluating } +{ #category : 'evaluating' } Retry class >> value: aNyladicClosure [ ^ self value: aNyladicClosure configuredBy: [ :retry | retry onException ] ] -{ #category : #evaluating } +{ #category : 'evaluating' } Retry class >> value: aNiladycBlock configuredBy: configurationAction [ ^ ( self configuredBy: configurationAction ) value: aNiladycBlock ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> backoffExponentiallyWithTimeSlot: aDuration [ self backoffExponentiallyWithTimeSlot: aDuration using: [ :integer | integer atRandom ] ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> backoffExponentiallyWithTimeSlot: aDuration using: aRandomizingAction [ "This strategy implements [Exponential Backoff](https://en.wikipedia.org/wiki/Exponential_backoff). @@ -84,19 +86,19 @@ Retry >> backoffExponentiallyWithTimeSlot: aDuration using: aRandomizingAction [ ] ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> every: aDuration [ waitActionBetweenRetries := [ aDuration wait ] ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> ignore: anException [ exceptionsToIgnore := exceptionsToIgnore , anException ] -{ #category : #initialization } +{ #category : 'initialization' } Retry >> initializeConfiguredBy: configurationAction [ maximumNumberOfAttempts := self class defaultMaximumNumberOfAttempts. @@ -109,26 +111,26 @@ Retry >> initializeConfiguredBy: configurationAction [ configurationAction value: self ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> on: anException [ exceptionToRetry := anException ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> on: anException evaluating: aDyadicBlock [ exceptionToRetry := anException. exceptionBasedActionBetweenRetries := aDyadicBlock ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> onException [ self on: Exception ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> upTo: aRetryCount [ AssertionChecker enforce: [ aRetryCount strictlyPositive ] @@ -136,7 +138,7 @@ Retry >> upTo: aRetryCount [ maximumNumberOfAttempts := aRetryCount + 1 ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> upTo: aRetryCount timesEvery: aDuration [ self @@ -144,7 +146,7 @@ Retry >> upTo: aRetryCount timesEvery: aDuration [ every: aDuration ] -{ #category : #evaluating } +{ #category : 'evaluating' } Retry >> value: aNyladicBlock [ 1 to: maximumNumberOfAttempts - 1 do: [ :tryCount | @@ -164,13 +166,13 @@ Retry >> value: aNyladicBlock [ ^ aNyladicBlock cull: maximumNumberOfAttempts ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> when: aCondition [ retryCondition := aCondition ] -{ #category : #configuring } +{ #category : 'configuring' } Retry >> when: aCondition evaluating: aDyadicBlock [ retryCondition := aCondition. diff --git a/source/Hyperspace-Model/SafeCURIE.class.st b/source/Hyperspace-Model/SafeCURIE.class.st new file mode 100644 index 0000000..89b12f0 --- /dev/null +++ b/source/Hyperspace-Model/SafeCURIE.class.st @@ -0,0 +1,94 @@ +" +A SafeCURIE is a compact syntax for URIs; used in contexts where a URI can also be used, to disambiguate. + +Normative Reference: + +• https://www.w3.org/TR/curie/ +" +Class { + #name : 'SafeCURIE', + #superclass : 'AbstractCURIE', + #instVars : [ + 'curie' + ], + #category : 'Hyperspace-Model', + #package : 'Hyperspace-Model' +} + +{ #category : 'instance creation' } +SafeCURIE class >> from: aCURIE [ + + ^ self new initializeFrom: aCURIE +] + +{ #category : 'instance creation' } +SafeCURIE class >> fromString: string [ + + AssertionChecker + check: [ :asserter | + asserter + enforce: [ string size > 2 ] + because: [ 'Cannot create a Safe CURIE from "<1s>"' expandMacrosWith: string ] + onSuccess: [ :successAsserter | + successAsserter + enforce: [ string first = $[ ] because: [ 'Missing "["' ]; + enforce: [ string last = $] ] because: [ 'Missing "]"' ] + ] + ] + configuredBy: [ :checker | checker raising: InstanceCreationFailed ]. + + ^ self from: ( CURIE fromString: ( string copyFrom: 2 to: string size - 1 ) ) +] + +{ #category : 'instance creation' } +SafeCURIE class >> prefixedBy: prefix referencing: relativeUrl [ + + ^ self from: ( CURIE prefixedBy: prefix referencing: relativeUrl ) +] + +{ #category : 'comparing' } +SafeCURIE >> = object [ + + ^ self equalityChecker + compare: #prefix; + compare: #relativeReference; + checkAgainst: object +] + +{ #category : 'converting' } +SafeCURIE >> asSafeCURIE [ + + ^ self +] + +{ #category : 'comparing' } +SafeCURIE >> hash [ + + ^ self equalityHashCombinator combineHashOf: self prefix with: self relativeReference +] + +{ #category : 'initialization' } +SafeCURIE >> initializeFrom: aCURIE [ + + curie := aCURIE +] + +{ #category : 'accessing' } +SafeCURIE >> prefix [ + + ^ curie prefix +] + +{ #category : 'printing' } +SafeCURIE >> printOn: stream [ + + stream nextPut: $[. + curie printOn: stream. + stream nextPut: $] +] + +{ #category : 'accessing' } +SafeCURIE >> relativeReference [ + + ^ curie relativeReference +] diff --git a/source/Hyperspace-Model/WebLink.class.st b/source/Hyperspace-Model/WebLink.class.st index 18518e1..35fba25 100644 --- a/source/Hyperspace-Model/WebLink.class.st +++ b/source/Hyperspace-Model/WebLink.class.st @@ -8,16 +8,18 @@ References https://tools.ietf.org/html/rfc5988#page-6 " Class { - #name : #WebLink, - #superclass : #Object, + #name : 'WebLink', + #superclass : 'Object', #instVars : [ 'parameters', 'url' ], - #category : #'Hyperspace-Model-IETF' + #category : 'Hyperspace-Model-IETF', + #package : 'Hyperspace-Model', + #tag : 'IETF' } -{ #category : #'private - preconditions' } +{ #category : 'private - preconditions' } WebLink class >> assertLinkValueFormatIsValid: urlCandidate [ AssertionCheckerBuilder new @@ -31,7 +33,7 @@ WebLink class >> assertLinkValueFormatIsValid: urlCandidate [ buildAndCheck ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } WebLink class >> fromString: aString [ | stream linkValueCandidate link | @@ -45,7 +47,7 @@ WebLink class >> fromString: aString [ ^ link ] -{ #category : #'private - parsing' } +{ #category : 'private - parsing' } WebLink class >> parseParametersOn: stream configuredIn: link [ [ stream atEnd ] whileFalse: [ @@ -66,19 +68,19 @@ WebLink class >> parseParametersOn: stream configuredIn: link [ ] ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } WebLink class >> to: aUrl [ ^ self new initializeTo: aUrl ] -{ #category : #'private - parsing' } +{ #category : 'private - parsing' } WebLink class >> trimTagsIn: urlCandidate [ ^ urlCandidate copyFrom: 2 to: urlCandidate size - 1 ] -{ #category : #comparing } +{ #category : 'comparing' } WebLink >> = anObject [ ^ self equalityChecker @@ -87,7 +89,7 @@ WebLink >> = anObject [ checkAgainst: anObject ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> addLanguageHint: aLanguageTag [ "The hreflang parameter, when present, is a hint indicating what the language @@ -99,25 +101,25 @@ WebLink >> addLanguageHint: aLanguageTag [ self parameterAt: 'hreflang' add: aLanguageTag asLanguageTag printString ] -{ #category : #converting } +{ #category : 'converting' } WebLink >> asByteArray [ ^ self printString asByteArray ] -{ #category : #printing } +{ #category : 'printing' } WebLink >> asString [ ^ self printString ] -{ #category : #converting } +{ #category : 'converting' } WebLink >> asWebLink [ ^ self ] -{ #category : #private } +{ #category : 'private' } WebLink >> assertNotEmpty: aKey [ AssertionChecker enforce: [ aKey notEmpty ] @@ -125,13 +127,13 @@ WebLink >> assertNotEmpty: aKey [ raising: InstanceCreationFailed ] -{ #category : #testing } +{ #category : 'testing' } WebLink >> hasParameters [ ^ parameters notNil and: [ parameters notEmpty ] ] -{ #category : #private } +{ #category : 'private' } WebLink >> hasTheSameParametersAs: aLink [ ^ self hasParameters = aLink hasParameters @@ -140,7 +142,7 @@ WebLink >> hasTheSameParametersAs: aLink [ aLink parameters includesAssociation: each]]] ] -{ #category : #comparing } +{ #category : 'comparing' } WebLink >> hash [ ^ self hasParameters @@ -148,13 +150,13 @@ WebLink >> hash [ otherwise: [ self url hash ] ] -{ #category : #'initialize - release' } +{ #category : 'initialize - release' } WebLink >> initializeTo: aUrl [ url := aUrl ] -{ #category : #'accessing - target parameters' } +{ #category : 'accessing - target parameters' } WebLink >> languageHints [ | value | @@ -165,13 +167,13 @@ WebLink >> languageHints [ ifFalse: [ Array with: value asLanguageTag ] ] -{ #category : #'accessing - target parameters' } +{ #category : 'accessing - target parameters' } WebLink >> mediaQueryHint [ ^ self parameterAt: 'media' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> mediaQueryHint: aCssMediaQuery [ "The media parameter, when present, is used to indicate intended @@ -182,13 +184,13 @@ WebLink >> mediaQueryHint: aCssMediaQuery [ self parameterAt: 'media' put: aCssMediaQuery asString ] -{ #category : #'accessing - target parameters' } +{ #category : 'accessing - target parameters' } WebLink >> mediaTypeHint [ ^ ( self parameterAt: 'type' ) asMediaType ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> mediaTypeHint: aMediaType [ "The type parameter, when present, is a hint indicating what the media type of the @@ -200,48 +202,48 @@ WebLink >> mediaTypeHint: aMediaType [ self parameterAt: 'type' put: aMediaType asMediaType printString ] -{ #category : #parameters } +{ #category : 'parameters' } WebLink >> parameterAt: key [ ^ self parameterAt: key ifAbsent: [ KeyNotFound signalFor: key ] ] -{ #category : #parameters } +{ #category : 'parameters' } WebLink >> parameterAt: aKey add: aValue [ self assertNotEmpty: aKey. self parameters at: aKey add: ( self quoteValueWhenNeeded: aValue ) ] -{ #category : #parameters } +{ #category : 'parameters' } WebLink >> parameterAt: key ifAbsent: block [ parameters ifNil: [ ^ block value ]. ^ self parameters at: key ifAbsent: block ] -{ #category : #parameters } +{ #category : 'parameters' } WebLink >> parameterAt: aKey put: aString [ self assertNotEmpty: aKey. self parameters at: aKey put: ( self quoteValueWhenNeeded: aString ) ] -{ #category : #parameters } +{ #category : 'parameters' } WebLink >> parameters [ parameters ifNil: [ parameters := MultiValueOrderedDictionary new ]. ^ parameters ] -{ #category : #copying } +{ #category : 'copying' } WebLink >> postCopy [ super postCopy. parameters := parameters copy ] -{ #category : #printing } +{ #category : 'printing' } WebLink >> printOn: stream [ stream @@ -258,7 +260,7 @@ WebLink >> printOn: stream [ nextPutAll: value ] ] ] -{ #category : #private } +{ #category : 'private' } WebLink >> quoteValueWhenNeeded: aString [ "Values including ; or , needs to be quoted" @@ -269,36 +271,36 @@ WebLink >> quoteValueWhenNeeded: aString [ otherwise: [ aString ] ] -{ #category : #accessing } +{ #category : 'accessing' } WebLink >> relationType [ ^ self parameterAt: 'rel' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> relationType: aRelation [ "The relation type of a link is conveyed in the rel parameter's value. The rel parameter MUST NOT appear more than once in a given link-value; occurrences after the first MUST be ignored by parsers." - self parameterAt: 'rel' put: aRelation + self parameterAt: 'rel' put: aRelation asString ] -{ #category : #parameters } +{ #category : 'parameters' } WebLink >> removeParameter: key [ parameters ifNil: [ ^ self ]. ^ self parameters removeKey: key ifAbsent: [ nil ] ] -{ #category : #'accessing - target parameters' } +{ #category : 'accessing - target parameters' } WebLink >> title [ ^ self parameterAt: 'title' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> title: aString [ "The title parameter, when present, is used to label the destination of a @@ -310,7 +312,7 @@ WebLink >> title: aString [ self parameterAt: 'title' put: aString ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toCollection [ "The target IRI points to a resource which represents the collection resource for the context IRI." @@ -318,7 +320,7 @@ WebLink >> toCollection [ self relationType: 'collection' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toCopyright [ "Refers to a copyright statement that applies to the link's context." @@ -326,7 +328,7 @@ WebLink >> toCopyright [ self relationType: 'copyright' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toEdit [ "Refers to a resource that can be used to edit the link's context." @@ -334,7 +336,7 @@ WebLink >> toEdit [ self relationType: 'edit' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toExternalSite [ "Refers to a resource that is not part of the same site as the current context." @@ -342,7 +344,7 @@ WebLink >> toExternalSite [ self relationType: 'external' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toFirst [ "An IRI that refers to the furthest preceding resource in a series of resources." @@ -350,7 +352,7 @@ WebLink >> toFirst [ self relationType: 'first' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toHelp [ "Refers to context-sensitive help." @@ -358,7 +360,7 @@ WebLink >> toHelp [ self relationType: 'help' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toIcon [ "Refers to an icon representing the link's context." @@ -366,7 +368,7 @@ WebLink >> toIcon [ self relationType: 'icon' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toItem [ "The target IRI points to a resource that is a member of the collection represented by the context IRI." @@ -374,7 +376,7 @@ WebLink >> toItem [ self relationType: 'item' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toLast [ "An IRI that refers to the furthest following resource in a series of resources." @@ -382,7 +384,7 @@ WebLink >> toLast [ self relationType: 'last' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toLatestVersion [ "Points to a resource containing the latest (e.g., current) version of the context." @@ -390,7 +392,7 @@ WebLink >> toLatestVersion [ self relationType: 'latest-version' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toLicense [ "Refers to a license associated with this context." @@ -398,7 +400,7 @@ WebLink >> toLicense [ self relationType: 'license' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toMyself [ "Conveys an identifier for the link's context. " @@ -406,7 +408,7 @@ WebLink >> toMyself [ self relationType: 'self' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toNext [ "Indicates that the link's context is a part of a series, and that the next in the series is the link target." @@ -414,7 +416,7 @@ WebLink >> toNext [ self relationType: 'next' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toParent [ "Refers to a parent document in a hierarchy of documents. " @@ -422,7 +424,7 @@ WebLink >> toParent [ self relationType: 'up' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toPayment [ "Indicates a resource where payment is accepted." @@ -430,7 +432,7 @@ WebLink >> toPayment [ self relationType: 'payment' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toPredecessorVersion [ "Points to a resource containing the predecessor version in the version history. " @@ -438,7 +440,7 @@ WebLink >> toPredecessorVersion [ self relationType: 'predecessor-version' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toPrevious [ "Indicates that the link's context is a part of a series, and that the previous in the series is the link target. " @@ -446,7 +448,7 @@ WebLink >> toPrevious [ self relationType: 'prev' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toProfile [ "Identifying that a resource representation conforms to a certain profile, @@ -455,7 +457,7 @@ WebLink >> toProfile [ self relationType: 'profile' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toSearch [ "Refers to a resource that can be used to search through the link's context and related resources." @@ -463,7 +465,7 @@ WebLink >> toSearch [ self relationType: 'search' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toSuccessorVersion [ "Points to a resource containing the successor version in the version history. " @@ -471,7 +473,7 @@ WebLink >> toSuccessorVersion [ self relationType: 'successor-version' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toTermsOfService [ "Refers to the terms of service associated with the link's context." @@ -479,7 +481,7 @@ WebLink >> toTermsOfService [ self relationType: 'terms-of-service' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toVersionHistory [ "Points to a resource containing the version history for the context. " @@ -487,7 +489,7 @@ WebLink >> toVersionHistory [ self relationType: 'version-history' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toWorkingCopy [ "Points to a working copy for this resource." @@ -495,7 +497,7 @@ WebLink >> toWorkingCopy [ self relationType: 'working-copy' ] -{ #category : #configuring } +{ #category : 'configuring' } WebLink >> toWorkingCopyOrigin [ "Points to the versioned resource from which this working copy was obtained." @@ -503,7 +505,7 @@ WebLink >> toWorkingCopyOrigin [ self relationType: 'working-copy-of' ] -{ #category : #accessing } +{ #category : 'accessing' } WebLink >> url [ ^ url diff --git a/source/Hyperspace-Model/package.st b/source/Hyperspace-Model/package.st index 4eaf267..07cac63 100644 --- a/source/Hyperspace-Model/package.st +++ b/source/Hyperspace-Model/package.st @@ -1 +1 @@ -Package { #name : #'Hyperspace-Model' } +Package { #name : 'Hyperspace-Model' } From 8f0272c4ac593f42fec80a5027f90612125bf391 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Fri, 14 Jun 2024 19:13:29 -0300 Subject: [PATCH 2/4] Fix GS64 failing tests --- source/Hyperspace-Model/AbstractCURIE.class.st | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/Hyperspace-Model/AbstractCURIE.class.st b/source/Hyperspace-Model/AbstractCURIE.class.st index 2126f74..09608fa 100644 --- a/source/Hyperspace-Model/AbstractCURIE.class.st +++ b/source/Hyperspace-Model/AbstractCURIE.class.st @@ -35,6 +35,12 @@ AbstractCURIE >> asSafeCURIE [ ^ self subclassResponsibility ] +{ #category : 'converting' } +AbstractCURIE >> asString [ + + ^ self printString +] + { #category : 'converting' } AbstractCURIE >> asWebLink [ From 334e4375afbc6d4251e072d71805319f91018a37 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Fri, 14 Jun 2024 19:24:54 -0300 Subject: [PATCH 3/4] Fix GS 64 incompatibility --- source/Hyperspace-Model/CURIE.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Hyperspace-Model/CURIE.class.st b/source/Hyperspace-Model/CURIE.class.st index a530a4c..1b6b1fc 100644 --- a/source/Hyperspace-Model/CURIE.class.st +++ b/source/Hyperspace-Model/CURIE.class.st @@ -19,7 +19,7 @@ Class { CURIE class >> fromString: string [ | segments | - segments := string splitOn: $:. + segments := $: split: string. AssertionChecker enforce: [ segments size = 2 ] because: [ 'Cannot create a CURIE from "<1s>"' expandMacrosWith: string ] From 78eb4b76d4c9fa66cc7b0b97562cd296fa064846 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Fri, 14 Jun 2024 19:44:38 -0300 Subject: [PATCH 4/4] Ignore method from coverage --- source/Hyperspace-Model/AbstractCURIE.class.st | 1 + 1 file changed, 1 insertion(+) diff --git a/source/Hyperspace-Model/AbstractCURIE.class.st b/source/Hyperspace-Model/AbstractCURIE.class.st index 09608fa..da5be69 100644 --- a/source/Hyperspace-Model/AbstractCURIE.class.st +++ b/source/Hyperspace-Model/AbstractCURIE.class.st @@ -14,6 +14,7 @@ AbstractCURIE class >> fromString: string [ { #category : 'testing' } AbstractCURIE class >> isAbstract [ + ^ self = AbstractCURIE ]