diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91bda58c..c0a78f77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,9 +7,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - smalltalk: [Pharo64-10] + smalltalk: [Pharo64-11] redis-version: [7] - mongodb-version: ['4.4'] + mongodb-version: ['7.0'] name: ${{ matrix.smalltalk }} services: postgres: diff --git a/.smalltalkci/.unit-tests.ston b/.smalltalkci/.unit-tests.ston index 757bfdf3..f3350b3a 100644 --- a/.smalltalkci/.unit-tests.ston +++ b/.smalltalkci/.unit-tests.ston @@ -3,22 +3,25 @@ SmalltalkCISpec { SCIMetacelloLoadSpec { #baseline : 'Mapless', #directory : '../src', - #load : [ 'Core', - 'Memory', - 'SQLite', - 'Postgres', - 'Mongo', - 'Redis' ], + #load : [ + 'Core', + 'Tests', + 'Memory-Tests', + 'SQLite-Tests', + 'Postgres-Tests', + 'Mongo-Tests', + 'Redis-Tests', + 'Redis-Observer-Tests' ], #platforms : [ #pharo ] } ], #testing : { #coverage : { #packages : [ - 'Mapless-Base-Core', - 'Mapless-Memory-Core', - 'Mapless-Postgres-Core', - 'Mapless-Mongo-Core', + 'Mapless-Base', + 'Mapless-Memory', + 'Mapless-Postgres', + 'Mapless-Mongo', 'Mapless-SQLite', 'Mapless-Redis', 'Mapless-Redis-Observer' diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..f06e4e18 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,3 @@ +ignore: + - "**/Manifest*.st" + - "**/*ReplicaSet*.st" diff --git a/src/BaselineOfMapless/BaselineOfMapless.class.st b/src/BaselineOfMapless/BaselineOfMapless.class.st index ebb5bcb3..f12968c4 100644 --- a/src/BaselineOfMapless/BaselineOfMapless.class.st +++ b/src/BaselineOfMapless/BaselineOfMapless.class.st @@ -22,26 +22,43 @@ Class { #category : #BaselineOfMapless } -{ #category : #baseline } +{ #category : #baselines } BaselineOfMapless >> baseline: spec [ + - spec - for: #common - do: [ self setUpBaseDependencies: spec. - self setUpPackages: spec. - spec - group: 'Core' with: #('Mapless-Base-Core'); - group: 'Memory' with: #('Mapless-Memory-Tests'); - group: 'Mongo' with: #('Mapless-Mongo-Tests'); - group: 'Redis' with: #('Mapless-Redis-Tests'); - group: 'Postgres' with: #('Mapless-Postgres-Tests'); - group: 'SQLite' with: #('Mapless-SQLite-Tests'); - group: 'UnQLite' with: #('Mapless-UnQLite-Tests'); - group: 'Benchmark' with: #('Mapless-Benchmark-Core'); - group: 'default' with: #('Memory' 'SQLite') ] + spec for: #common do: [ + self setUpBaseDependencies: spec. + self setUpPackages: spec. + spec + group: 'Core' with: #( 'Mapless-Base' ); + group: 'Tests' with: #( 'Mapless-Base' 'Mapless-Tests' ); + group: 'Memory' with: #( 'Mapless-Memory' ); + group: 'Memory-Tests' + with: #( 'Mapless-Memory' 'Mapless-Memory-Tests' ); + group: 'Mongo' with: #( 'Mapless-Mongo' ); + group: 'Mongo-Tests' + with: #( 'Mapless-Mongo' 'Mapless-Mongo-Tests' ); + group: 'Mongo-ReplicaSet-Tests' + with: #( 'Mapless-Mongo-ReplicaSet-Tests' ); + group: 'Redis' with: #( 'Mapless-Redis' ); + group: 'Redis-Tests' + with: #( 'Mapless-Redis' 'Mapless-Redis-Tests' ); + group: 'Redis-Observer-Tests' + with: #( 'Mapless-Redis-Observer' 'Mapless-Redis-Observer-Tests' ); + group: 'Postgres' with: #( 'Mapless-Postgres' ); + group: 'Postgres-Tests' + with: #( 'Mapless-Postgres' 'Mapless-Postgres-Tests' ); + group: 'SQLite' with: #( 'Mapless-SQLite' ); + group: 'SQLite-Tests' + with: #( 'Mapless-SQLite' 'Mapless-SQLite-Tests' ); + group: 'UnQLite' with: #( 'Mapless-UnQLite' ); + group: 'UnQLite-Tests' + with: #( 'Mapless-UnQLite' 'Mapless-UnQLite-Tests' ); + group: 'Benchmark' with: #( 'Mapless-Benchmark-Core' ); + group: 'default' with: #( 'Memory' 'SQLite' ) ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpBaseDependencies: spec [ spec baseline: 'JSON' @@ -51,24 +68,24 @@ BaselineOfMapless >> setUpBaseDependencies: spec [ with: [ spec repository: 'github://svenvc/NeoJSON:v18/repository' ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpBasePackages: spec [ spec - package: 'Mapless-Base-Core' + package: 'Mapless-Base' with: [ spec requires: 'JSON' ]. spec - package: 'Mapless-Tests-Base' - with: [ spec requires: 'Mapless-Base-Core' ]. + package: 'Mapless-Tests' + with: [ spec requires: 'Mapless-Base' ]. spec - package: 'Mapless-Memory-Core' - with: [ spec requires: #('Mapless-Base-Core') ]. + package: 'Mapless-Memory' + with: [ spec requires: #('Mapless-Base') ]. spec package: 'Mapless-Memory-Tests' - with: [ spec requires: #('Mapless-Memory-Core') ]. + with: [ spec requires: #('Mapless-Memory') ]. ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpMongoDependencies: spec [ spec baseline: 'MongoTalk' with: [ @@ -77,14 +94,17 @@ BaselineOfMapless >> setUpMongoDependencies: spec [ loads: #( Client 'Mongo-DriverLegacy' ) ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpMongoPackages: spec [ spec - package: 'Mapless-Mongo-Core' - with: [ spec requires: #('Mapless-Base-Core' 'MongoTalk') ]. + package: 'Mapless-Mongo' + with: [ spec requires: #('Mapless-Base' 'MongoTalk') ]. spec package: 'Mapless-Mongo-Tests' - with: [ spec requires: #('Mapless-Mongo-Core' 'Mapless-Tests-Base') ]. + with: [ spec requires: #('Mapless-Mongo' 'Mapless-Tests') ]. + spec + package: 'Mapless-Mongo-ReplicaSet-Tests' + with: [ spec requires: #('Mapless-Mongo-Tests') ]. spec package: 'Mapless-Mongo-Log' with: [ spec requires: #('Mapless-Mongo-Tests' 'NeoJSON') ]. @@ -93,7 +113,7 @@ BaselineOfMapless >> setUpMongoPackages: spec [ with: [ spec requires: 'Mapless-Mongo-Tests' ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpPackages: spec [ self setUpBaseDependencies: spec. self setUpBasePackages: spec. @@ -114,22 +134,22 @@ BaselineOfMapless >> setUpPackages: spec [ self setUpUnQLitePackages: spec ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpPostgresDependencies: spec [ spec baseline: 'P3' with: [ spec repository: 'github://svenvc/P3:v1.4' ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpPostgresPackages: spec [ spec - package: 'Mapless-Postgres-Core' - with: [ spec requires: #('Mapless-Base-Core' 'P3') ]. + package: 'Mapless-Postgres' + with: [ spec requires: #('Mapless-Base' 'P3') ]. spec package: 'Mapless-Postgres-Tests' - with: [ spec requires: #('Mapless-Postgres-Core' 'Mapless-Tests-Base') ] + with: [ spec requires: #('Mapless-Postgres' 'Mapless-Tests') ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpRedisDependencies: spec [ spec baseline: 'RediStick' @@ -138,27 +158,27 @@ BaselineOfMapless >> setUpRedisDependencies: spec [ loads: #('Core' 'ConnectionPool') ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpRedisPackages: spec [ spec package: 'Mapless-Redis' - with: [ spec requires: #( 'Mapless-Base-Core' 'RediStick' ) ]. + with: [ spec requires: #( 'Mapless-Base' 'RediStick' ) ]. spec package: 'Mapless-Redis-Observer' - with: [ spec requires: #( 'Mapless-Base-Core' ) ]. + with: [ spec requires: #( 'Mapless-Redis' ) ]. - spec package: 'Mapless-Redis-Observer-Tests' with: [ + spec package: 'Mapless-Redis-Observer-Tests' with: [ spec requires: #( 'Mapless-Redis-Observer' 'Mapless-Redis-Tests' - 'Mapless-Tests-Base' ) ]. - + 'Mapless-Tests' ) ]. + spec package: 'Mapless-Redis-Tests' - with: [ spec requires: #( 'Mapless-Redis' 'Mapless-Tests-Base' ) ]. + with: [ spec requires: #( 'Mapless-Redis' 'Mapless-Tests' ) ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpSQLiteDependencies: spec [ spec baseline: 'SQLite3' @@ -167,31 +187,31 @@ BaselineOfMapless >> setUpSQLiteDependencies: spec [ loads: #('Core') ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpSQLitePackages: spec [ spec - package: 'Mapless-SQLite-Core' - with: [ spec requires: #('Mapless-Base-Core' 'SQLite3') ]. + package: 'Mapless-SQLite' + with: [ spec requires: #('Mapless-Base' 'SQLite3') ]. spec package: 'Mapless-SQLite-Tests' - with: [ spec requires: #('Mapless-SQLite-Core' 'Mapless-Tests-Base') ] + with: [ spec requires: #('Mapless-SQLite' 'Mapless-Tests') ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpUnQLiteDependencies: spec [ spec baseline: 'PunQLite' with: [ spec - repository: 'github://mumez/PunQLite:aab064c2e003ef18fcdf8dad2a139fa4b36b6ed6/repository'; + repository: 'github://mumez/PunQLite:v2.0.1/repository'; loads: #('Core') ] ] -{ #category : #baseline } +{ #category : #dependencies } BaselineOfMapless >> setUpUnQLitePackages: spec [ spec - package: 'Mapless-UnQLite-Core' - with: [ spec requires: #('Mapless-Base-Core' 'PunQLite') ]. + package: 'Mapless-UnQLite' + with: [ spec requires: #('Mapless-Base' 'PunQLite') ]. spec package: 'Mapless-UnQLite-Tests' - with: [ spec requires: #('Mapless-UnQLite-Core' 'Mapless-Tests-Base') ] + with: [ spec requires: #('Mapless-UnQLite' 'Mapless-Tests') ] ] diff --git a/src/Mapless-Base-Core/MaplessClassNotFound.class.st b/src/Mapless-Base-Core/MaplessClassNotFound.class.st deleted file mode 100644 index a17c76d7..00000000 --- a/src/Mapless-Base-Core/MaplessClassNotFound.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #MaplessClassNotFound, - #superclass : #MaplessError, - #category : #'Mapless-Base-Core-Errors' -} diff --git a/src/Mapless-Base-Core/MaplessTrivialResolver.class.st b/src/Mapless-Base-Core/MaplessTrivialResolver.class.st deleted file mode 100644 index 8bba1470..00000000 --- a/src/Mapless-Base-Core/MaplessTrivialResolver.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #MaplessTrivialResolver, - #superclass : #MaplessResolver, - #category : #'Mapless-Base-Core-Resolvers' -} diff --git a/src/Mapless-Base-Core/package.st b/src/Mapless-Base-Core/package.st deleted file mode 100644 index bcf2e2f4..00000000 --- a/src/Mapless-Base-Core/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Mapless-Base-Core' } diff --git a/src/Mapless-Base-Core/Dictionary.extension.st b/src/Mapless-Base/Dictionary.extension.st similarity index 93% rename from src/Mapless-Base-Core/Dictionary.extension.st rename to src/Mapless-Base/Dictionary.extension.st index 745ccfdf..d2978c0b 100644 --- a/src/Mapless-Base-Core/Dictionary.extension.st +++ b/src/Mapless-Base/Dictionary.extension.st @@ -1,6 +1,6 @@ Extension { #name : #Dictionary } -{ #category : #'*Mapless-Base-Core' } +{ #category : #'*Mapless-Base' } Dictionary >> asJsonObjectIn: aMaplessRepository [ "Answers a JSON object based on the contents of this dictionary." diff --git a/src/Mapless-Base-Core/JsonObject.extension.st b/src/Mapless-Base/JsonObject.extension.st similarity index 71% rename from src/Mapless-Base-Core/JsonObject.extension.st rename to src/Mapless-Base/JsonObject.extension.st index 121d0ce7..a69ddd1b 100644 --- a/src/Mapless-Base-Core/JsonObject.extension.st +++ b/src/Mapless-Base/JsonObject.extension.st @@ -1,6 +1,6 @@ Extension { #name : #JsonObject } -{ #category : #'*Mapless-Base-Core' } +{ #category : #'*Mapless-Base' } JsonObject >> asJsonObjectIn: aMaplessRepository [ ^ self ] diff --git a/src/Mapless-Base-Core/ManifestMaplessBaseCore.class.st b/src/Mapless-Base/ManifestMaplessBase.class.st similarity index 71% rename from src/Mapless-Base-Core/ManifestMaplessBaseCore.class.st rename to src/Mapless-Base/ManifestMaplessBase.class.st index 8762deec..9c18e888 100644 --- a/src/Mapless-Base-Core/ManifestMaplessBaseCore.class.st +++ b/src/Mapless-Base/ManifestMaplessBase.class.st @@ -2,12 +2,12 @@ I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser " Class { - #name : #ManifestMaplessBaseCore, + #name : #ManifestMaplessBase, #superclass : #PackageManifest, - #category : #'Mapless-Base-Core-Manifest' + #category : #'Mapless-Base-Manifest' } { #category : #'code-critics' } -ManifestMaplessBaseCore class >> ruleRBSentNotImplementedRuleV1FalsePositive [ +ManifestMaplessBase class >> ruleRBSentNotImplementedRuleV1FalsePositive [ ^ #(#(#(#RGPackageDefinition #(#'Mapless-Base-Core')) #'2021-09-18T15:55:40.299821-03:00') #(#(#RGClassDefinition #(#MaplessReference)) #'2022-03-13T14:06:38.150255-03:00') ) ] diff --git a/src/Mapless-Base-Core/Mapless.class.st b/src/Mapless-Base/Mapless.class.st similarity index 98% rename from src/Mapless-Base-Core/Mapless.class.st rename to src/Mapless-Base/Mapless.class.st index 00cc9012..006135cd 100644 --- a/src/Mapless-Base-Core/Mapless.class.st +++ b/src/Mapless-Base/Mapless.class.st @@ -13,7 +13,7 @@ Class { #instVars : [ 'data' ], - #category : #'Mapless-Base-Core-Models' + #category : #'Mapless-Base-Models' } { #category : #accessing } @@ -196,7 +196,7 @@ Mapless class >> isAbstract [ ^ self == AnAbstractModelClass" - ^ false + ^ self == Mapless ] { #category : #testing } @@ -244,7 +244,7 @@ Mapless class >> pluralName [ Any subclass can override its own custom name. The default plural name is the singular name in lower case plus an 's' so beware of irregular nouns." - + self deprecated: 'Application responsibility'. ^ self singularName , 's' ] @@ -253,7 +253,7 @@ Mapless class >> singularName [ "Answers the string expected in a nicely designed API. Any subclass can override its own custom name. The default name is the class name in lowercase." - + self deprecated: 'Application responsibility'. ^ self name asLowercase ] @@ -665,10 +665,11 @@ Mapless >> onBeforeUpsert [ ] { #category : #actions } -Mapless >> sanitize: someFields [ - "Removes someFields from the receiver." +Mapless >> sanitize: someProperties [ + "Removes someProperties from the receiver." - someFields do: [ :key | self data removeKey: key ifAbsent: [ nil ] ] + someProperties do: [ :key | + self maplessData removeKey: key ifAbsent: [ nil ] ] ] { #category : #actions } diff --git a/src/Mapless-Base-Core/MaplessAbstractPool.class.st b/src/Mapless-Base/MaplessAbstractPool.class.st similarity index 85% rename from src/Mapless-Base-Core/MaplessAbstractPool.class.st rename to src/Mapless-Base/MaplessAbstractPool.class.st index e1fa5e3b..cda49406 100644 --- a/src/Mapless-Base-Core/MaplessAbstractPool.class.st +++ b/src/Mapless-Base/MaplessAbstractPool.class.st @@ -11,26 +11,28 @@ Class { 'username', 'password' ], - #category : #'Mapless-Base-Core-Repositories' + #category : #'Mapless-Base-Repositories' } { #category : #'instance creation' } MaplessAbstractPool class >> hostname: aString port: anInteger [ + ^ self - hostname: aString - port: anInteger - username: nil - password: nil + hostname: aString + port: anInteger + username: nil + password: nil ] { #category : #'instance creation' } MaplessAbstractPool class >> hostname: aString port: anInteger username: anUsernameOrNil password: aPasswordOrNil [ + ^ self new - hostname: aString; - port: anInteger; - username: anUsernameOrNil; - password: aPasswordOrNil; - yourself + hostname: aString; + port: anInteger; + username: anUsernameOrNil; + password: aPasswordOrNil; + yourself ] { #category : #'instance creation' } @@ -46,6 +48,12 @@ MaplessAbstractPool >> currentClientDynamicVariableClass [ ^ self subclassResponsibility ] +{ #category : #testing } +MaplessAbstractPool >> hasHealthChecker [ + + ^ false +] + { #category : #accessing } MaplessAbstractPool >> hostname [ ^ hostname diff --git a/src/Mapless-Base/MaplessClassNotFound.class.st b/src/Mapless-Base/MaplessClassNotFound.class.st new file mode 100644 index 00000000..5d9f3e9e --- /dev/null +++ b/src/Mapless-Base/MaplessClassNotFound.class.st @@ -0,0 +1,8 @@ +" +I signal when Mapless is having an issue related to finding a class to resolve something +" +Class { + #name : #MaplessClassNotFound, + #superclass : #MaplessError, + #category : #'Mapless-Base-Errors' +} diff --git a/src/Mapless-Base-Core/MaplessCollectionToClassNameResolver.class.st b/src/Mapless-Base/MaplessCollectionToClassNameResolver.class.st similarity index 80% rename from src/Mapless-Base-Core/MaplessCollectionToClassNameResolver.class.st rename to src/Mapless-Base/MaplessCollectionToClassNameResolver.class.st index 39032cab..3ba0a27f 100644 --- a/src/Mapless-Base-Core/MaplessCollectionToClassNameResolver.class.st +++ b/src/Mapless-Base/MaplessCollectionToClassNameResolver.class.st @@ -4,5 +4,5 @@ I expect classes in this image to correspond to collection names (camel sensitiv Class { #name : #MaplessCollectionToClassNameResolver, #superclass : #MaplessResolver, - #category : #'Mapless-Base-Core-Resolvers' + #category : #'Mapless-Base-Resolvers' } diff --git a/src/Mapless-Base-Core/MaplessCurrentRepository.class.st b/src/Mapless-Base/MaplessCurrentRepository.class.st similarity index 78% rename from src/Mapless-Base-Core/MaplessCurrentRepository.class.st rename to src/Mapless-Base/MaplessCurrentRepository.class.st index fdfc7733..dc84d995 100644 --- a/src/Mapless-Base-Core/MaplessCurrentRepository.class.st +++ b/src/Mapless-Base/MaplessCurrentRepository.class.st @@ -5,5 +5,5 @@ A MaplessCurrentPersistenceStrategy is a dinamyc varible to hold the current rep Class { #name : #MaplessCurrentRepository, #superclass : #DynamicVariable, - #category : #'Mapless-Base-Core-Repositories' + #category : #'Mapless-Base-Repositories' } diff --git a/src/Mapless-Base-Core/MaplessCustomCollectionNameResolver.class.st b/src/Mapless-Base/MaplessCustomCollectionNameResolver.class.st similarity index 87% rename from src/Mapless-Base-Core/MaplessCustomCollectionNameResolver.class.st rename to src/Mapless-Base/MaplessCustomCollectionNameResolver.class.st index cc516b74..d3126ac9 100644 --- a/src/Mapless-Base-Core/MaplessCustomCollectionNameResolver.class.st +++ b/src/Mapless-Base/MaplessCustomCollectionNameResolver.class.st @@ -7,7 +7,7 @@ Class { #instVars : [ 'translations' ], - #category : #'Mapless-Base-Core-Resolvers' + #category : #'Mapless-Base-Resolvers' } { #category : #initialization } @@ -21,7 +21,7 @@ MaplessCustomCollectionNameResolver >> maplessClassNameFor: aJsonObject in: aMap classSelector := aJsonObject at: '_c'. ^ self translations at: classSelector - ifAbsent: [ self error: 'This resolver could not translate ' , classSelector ] + ifAbsent: [ MaplessClassNotFound signal: 'This resolver could not translate ' , classSelector ] ] { #category : #accessing } diff --git a/src/Mapless-Base-Core/MaplessError.class.st b/src/Mapless-Base/MaplessError.class.st similarity index 84% rename from src/Mapless-Base-Core/MaplessError.class.st rename to src/Mapless-Base/MaplessError.class.st index b450d0b2..fdf05b42 100644 --- a/src/Mapless-Base-Core/MaplessError.class.st +++ b/src/Mapless-Base/MaplessError.class.st @@ -4,7 +4,7 @@ I'm the type of Error specific to Mapless scenarios Class { #name : #MaplessError, #superclass : #Error, - #category : #'Mapless-Base-Core-Errors' + #category : #'Mapless-Base-Errors' } { #category : #accessing } diff --git a/src/Mapless-Base-Core/MaplessMaximumPoolClientsReached.class.st b/src/Mapless-Base/MaplessMaximumPoolClientsReached.class.st similarity index 78% rename from src/Mapless-Base-Core/MaplessMaximumPoolClientsReached.class.st rename to src/Mapless-Base/MaplessMaximumPoolClientsReached.class.st index 8235f7f5..d4a81172 100644 --- a/src/Mapless-Base-Core/MaplessMaximumPoolClientsReached.class.st +++ b/src/Mapless-Base/MaplessMaximumPoolClientsReached.class.st @@ -4,5 +4,5 @@ Thrown when a pool tries to create a client beyond its limits. Class { #name : #MaplessMaximumPoolClientsReached, #superclass : #MaplessError, - #category : #'Mapless-Base-Core-Errors' + #category : #'Mapless-Base-Errors' } diff --git a/src/Mapless-Base-Core/MaplessMaximumReadWritePoolClientsReached.class.st b/src/Mapless-Base/MaplessMaximumReadWritePoolClientsReached.class.st similarity index 69% rename from src/Mapless-Base-Core/MaplessMaximumReadWritePoolClientsReached.class.st rename to src/Mapless-Base/MaplessMaximumReadWritePoolClientsReached.class.st index 9be96733..1d6a9547 100644 --- a/src/Mapless-Base-Core/MaplessMaximumReadWritePoolClientsReached.class.st +++ b/src/Mapless-Base/MaplessMaximumReadWritePoolClientsReached.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessMaximumReadWritePoolClientsReached, #superclass : #MaplessError, - #category : #'Mapless-Base-Core-Errors' + #category : #'Mapless-Base-Errors' } diff --git a/src/Mapless-Base-Core/MaplessMemoryCollectionToClassNameResolver.class.st b/src/Mapless-Base/MaplessMemoryCollectionToClassNameResolver.class.st similarity index 85% rename from src/Mapless-Base-Core/MaplessMemoryCollectionToClassNameResolver.class.st rename to src/Mapless-Base/MaplessMemoryCollectionToClassNameResolver.class.st index bb6f8254..5125187d 100644 --- a/src/Mapless-Base-Core/MaplessMemoryCollectionToClassNameResolver.class.st +++ b/src/Mapless-Base/MaplessMemoryCollectionToClassNameResolver.class.st @@ -1,7 +1,7 @@ Class { #name : #MaplessMemoryCollectionToClassNameResolver, #superclass : #MaplessResolver, - #category : #'Mapless-Base-Core-Resolvers' + #category : #'Mapless-Base-Resolvers' } { #category : #accessing } diff --git a/src/Mapless-Base-Core/MaplessModelDataError.class.st b/src/Mapless-Base/MaplessModelDataError.class.st similarity index 64% rename from src/Mapless-Base-Core/MaplessModelDataError.class.st rename to src/Mapless-Base/MaplessModelDataError.class.st index b7832855..4fb8ca4a 100644 --- a/src/Mapless-Base-Core/MaplessModelDataError.class.st +++ b/src/Mapless-Base/MaplessModelDataError.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessModelDataError, #superclass : #MaplessError, - #category : #'Mapless-Base-Core-Errors' + #category : #'Mapless-Base-Errors' } diff --git a/src/Mapless-Base-Core/MaplessModelGetterIsMissing.class.st b/src/Mapless-Base/MaplessModelGetterIsMissing.class.st similarity index 65% rename from src/Mapless-Base-Core/MaplessModelGetterIsMissing.class.st rename to src/Mapless-Base/MaplessModelGetterIsMissing.class.st index 64458ba0..c0bbac8f 100644 --- a/src/Mapless-Base-Core/MaplessModelGetterIsMissing.class.st +++ b/src/Mapless-Base/MaplessModelGetterIsMissing.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessModelGetterIsMissing, #superclass : #MaplessError, - #category : #'Mapless-Base-Core-Errors' + #category : #'Mapless-Base-Errors' } diff --git a/src/Mapless-Base-Core/MaplessModelMetadataError.class.st b/src/Mapless-Base/MaplessModelMetadataError.class.st similarity index 65% rename from src/Mapless-Base-Core/MaplessModelMetadataError.class.st rename to src/Mapless-Base/MaplessModelMetadataError.class.st index 9cb6d18b..835df74c 100644 --- a/src/Mapless-Base-Core/MaplessModelMetadataError.class.st +++ b/src/Mapless-Base/MaplessModelMetadataError.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessModelMetadataError, #superclass : #MaplessError, - #category : #'Mapless-Base-Core-Errors' + #category : #'Mapless-Base-Errors' } diff --git a/src/Mapless-Base-Core/MaplessReference.class.st b/src/Mapless-Base/MaplessReference.class.st similarity index 99% rename from src/Mapless-Base-Core/MaplessReference.class.st rename to src/Mapless-Base/MaplessReference.class.st index 140ba769..4fec1de0 100644 --- a/src/Mapless-Base-Core/MaplessReference.class.st +++ b/src/Mapless-Base/MaplessReference.class.st @@ -9,7 +9,7 @@ Class { 'data', 'repository' ], - #category : #'Mapless-Base-Core-Models' + #category : #'Mapless-Base-Models' } { #category : #actions } diff --git a/src/Mapless-Base-Core/MaplessRepository.class.st b/src/Mapless-Base/MaplessRepository.class.st similarity index 99% rename from src/Mapless-Base-Core/MaplessRepository.class.st rename to src/Mapless-Base/MaplessRepository.class.st index 142a7c6e..5885b0c0 100644 --- a/src/Mapless-Base-Core/MaplessRepository.class.st +++ b/src/Mapless-Base/MaplessRepository.class.st @@ -17,7 +17,7 @@ Class { 'accessor', 'resolver' ], - #category : #'Mapless-Base-Core-Repositories' + #category : #'Mapless-Base-Repositories' } { #category : #actions } diff --git a/src/Mapless-Base-Core/MaplessResolver.class.st b/src/Mapless-Base/MaplessResolver.class.st similarity index 96% rename from src/Mapless-Base-Core/MaplessResolver.class.st rename to src/Mapless-Base/MaplessResolver.class.st index 24aff647..9076514d 100644 --- a/src/Mapless-Base-Core/MaplessResolver.class.st +++ b/src/Mapless-Base/MaplessResolver.class.st @@ -1,10 +1,10 @@ " -I'm the abstraction of the resolvers that helps a concrete MaplessRepository how to resolve classes in the image and collection names. +I'm the abstraction of the resolvers that helps a concrete MaplessRepository know how to resolve classes in the image and collection names. " Class { #name : #MaplessResolver, #superclass : #Object, - #category : #'Mapless-Base-Core-Resolvers' + #category : #'Mapless-Base-Resolvers' } { #category : #converting } diff --git a/src/Mapless-Base-Core/MaplessResourcePolicy.class.st b/src/Mapless-Base/MaplessResourcePolicy.class.st similarity index 76% rename from src/Mapless-Base-Core/MaplessResourcePolicy.class.st rename to src/Mapless-Base/MaplessResourcePolicy.class.st index 659e722b..6ce9dd32 100644 --- a/src/Mapless-Base-Core/MaplessResourcePolicy.class.st +++ b/src/Mapless-Base/MaplessResourcePolicy.class.st @@ -4,5 +4,5 @@ I'm the abstract class of helpers that are dedicated to allocate resources. Class { #name : #MaplessResourcePolicy, #superclass : #Object, - #category : #'Mapless-Base-Core-Resources' + #category : #'Mapless-Base-Resources' } diff --git a/src/Mapless-Base/MaplessTrivialResolver.class.st b/src/Mapless-Base/MaplessTrivialResolver.class.st new file mode 100644 index 00000000..f189fd7e --- /dev/null +++ b/src/Mapless-Base/MaplessTrivialResolver.class.st @@ -0,0 +1,8 @@ +" +I'm the trivial resolution so I expect collection names tp be the same as the Mapless class names +" +Class { + #name : #MaplessTrivialResolver, + #superclass : #MaplessResolver, + #category : #'Mapless-Base-Resolvers' +} diff --git a/src/Mapless-Base-Core/MaplessUnavailableClient.class.st b/src/Mapless-Base/MaplessUnavailableClient.class.st similarity index 64% rename from src/Mapless-Base-Core/MaplessUnavailableClient.class.st rename to src/Mapless-Base/MaplessUnavailableClient.class.st index af66d272..5e51932c 100644 --- a/src/Mapless-Base-Core/MaplessUnavailableClient.class.st +++ b/src/Mapless-Base/MaplessUnavailableClient.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessUnavailableClient, #superclass : #MaplessError, - #category : #'Mapless-Base-Core-Errors' + #category : #'Mapless-Base-Errors' } diff --git a/src/Mapless-Base-Core/MaplessUnsavedSubmodel.class.st b/src/Mapless-Base/MaplessUnsavedSubmodel.class.st similarity index 64% rename from src/Mapless-Base-Core/MaplessUnsavedSubmodel.class.st rename to src/Mapless-Base/MaplessUnsavedSubmodel.class.st index b782a96d..a51f239f 100644 --- a/src/Mapless-Base-Core/MaplessUnsavedSubmodel.class.st +++ b/src/Mapless-Base/MaplessUnsavedSubmodel.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessUnsavedSubmodel, #superclass : #MaplessError, - #category : #'Mapless-Base-Core-Errors' + #category : #'Mapless-Base-Errors' } diff --git a/src/Mapless-Base-Core/MaplessVoyageWithMaplessSuffixResolver.class.st b/src/Mapless-Base/MaplessVoyageWithMaplessSuffixResolver.class.st similarity index 99% rename from src/Mapless-Base-Core/MaplessVoyageWithMaplessSuffixResolver.class.st rename to src/Mapless-Base/MaplessVoyageWithMaplessSuffixResolver.class.st index 4892208a..2497b72f 100644 --- a/src/Mapless-Base-Core/MaplessVoyageWithMaplessSuffixResolver.class.st +++ b/src/Mapless-Base/MaplessVoyageWithMaplessSuffixResolver.class.st @@ -7,7 +7,7 @@ Class { #instVars : [ 'suffix' ], - #category : #'Mapless-Base-Core-Resolvers' + #category : #'Mapless-Base-Resolvers' } { #category : #testing } diff --git a/src/Mapless-Base-Core/MaplessWeightedNode.class.st b/src/Mapless-Base/MaplessWeightedNode.class.st similarity index 93% rename from src/Mapless-Base-Core/MaplessWeightedNode.class.st rename to src/Mapless-Base/MaplessWeightedNode.class.st index 011bedae..c22ccb2d 100644 --- a/src/Mapless-Base-Core/MaplessWeightedNode.class.st +++ b/src/Mapless-Base/MaplessWeightedNode.class.st @@ -10,7 +10,7 @@ Class { 'top', 'bottom' ], - #category : #'Mapless-Base-Core-Resources' + #category : #'Mapless-Base-Resources' } { #category : #'instance creation' } @@ -43,8 +43,11 @@ MaplessWeightedNode >> matches: aRandomValue [ { #category : #printing } MaplessWeightedNode >> printOn: aStream [ + super printOn: aStream. - aStream << ('({1})' format: {value asString}) + aStream << ('({1}@{2})' format: { + weight asString. + value asString }) ] { #category : #actions } diff --git a/src/Mapless-Base-Core/MaplessWeightedRandomPolicy.class.st b/src/Mapless-Base/MaplessWeightedRandomPolicy.class.st similarity index 98% rename from src/Mapless-Base-Core/MaplessWeightedRandomPolicy.class.st rename to src/Mapless-Base/MaplessWeightedRandomPolicy.class.st index 2b316fc1..4f52a37e 100644 --- a/src/Mapless-Base-Core/MaplessWeightedRandomPolicy.class.st +++ b/src/Mapless-Base/MaplessWeightedRandomPolicy.class.st @@ -9,7 +9,7 @@ Class { 'random', 'totalWeight' ], - #category : #'Mapless-Base-Core-Resources' + #category : #'Mapless-Base-Resources' } { #category : #'instance creation' } diff --git a/src/Mapless-Base-Core/Object.extension.st b/src/Mapless-Base/Object.extension.st similarity index 66% rename from src/Mapless-Base-Core/Object.extension.st rename to src/Mapless-Base/Object.extension.st index 1f8f7cc2..7a75db2e 100644 --- a/src/Mapless-Base-Core/Object.extension.st +++ b/src/Mapless-Base/Object.extension.st @@ -1,11 +1,11 @@ Extension { #name : #Object } -{ #category : #'*Mapless-Base-Core' } +{ #category : #'*Mapless-Base' } Object >> asJSONString [ ^ String streamContents: [ :str | self jsonWriteOn: str ] ] -{ #category : #'*Mapless-Base-Core' } +{ #category : #'*Mapless-Base' } Object >> unreferenced [ ^ self ] diff --git a/src/Mapless-Base-Core/OrderedJsonObject.extension.st b/src/Mapless-Base/OrderedJsonObject.extension.st similarity index 74% rename from src/Mapless-Base-Core/OrderedJsonObject.extension.st rename to src/Mapless-Base/OrderedJsonObject.extension.st index 27cf9854..6dfb1d32 100644 --- a/src/Mapless-Base-Core/OrderedJsonObject.extension.st +++ b/src/Mapless-Base/OrderedJsonObject.extension.st @@ -1,11 +1,11 @@ Extension { #name : #OrderedJsonObject } -{ #category : #'*Mapless-Base-Core' } +{ #category : #'*Mapless-Base' } OrderedJsonObject >> asJsonObjectIn: aMaplessRepository [ ^ self ] -{ #category : #'*Mapless-Base-Core' } +{ #category : #'*Mapless-Base' } OrderedJsonObject >> mpWriteSelector [ self class == OrderedJsonObject ifTrue: [ ^ #writeMap: ]. diff --git a/src/Mapless-Base-Core/ProtoObject.extension.st b/src/Mapless-Base/ProtoObject.extension.st similarity index 66% rename from src/Mapless-Base-Core/ProtoObject.extension.st rename to src/Mapless-Base/ProtoObject.extension.st index 0b4f794e..9c9c2ca9 100644 --- a/src/Mapless-Base-Core/ProtoObject.extension.st +++ b/src/Mapless-Base/ProtoObject.extension.st @@ -1,6 +1,6 @@ Extension { #name : #ProtoObject } -{ #category : #'*Mapless-Base-Core' } +{ #category : #'*Mapless-Base' } ProtoObject >> isMapless [ ^ false ] diff --git a/src/Mapless-Base/package.st b/src/Mapless-Base/package.st new file mode 100644 index 00000000..f9c113f2 --- /dev/null +++ b/src/Mapless-Base/package.st @@ -0,0 +1 @@ +Package { #name : #'Mapless-Base' } diff --git a/src/Mapless-Memory-Core/package.st b/src/Mapless-Memory-Core/package.st deleted file mode 100644 index 6f6bd95c..00000000 --- a/src/Mapless-Memory-Core/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Mapless-Memory-Core' } diff --git a/src/Mapless-Memory-Tests/MaplessMemoryRepositoryTest.class.st b/src/Mapless-Memory-Tests/MaplessMemoryRepositoryTest.class.st index 7a9aa813..8cb55552 100644 --- a/src/Mapless-Memory-Tests/MaplessMemoryRepositoryTest.class.st +++ b/src/Mapless-Memory-Tests/MaplessMemoryRepositoryTest.class.st @@ -11,10 +11,10 @@ Class { } { #category : #actions } -MaplessMemoryRepositoryTest >> addDummyPeople [ +MaplessMemoryRepositoryTest >> addSamplePeople [ | guy | 1 to: 10 do: [ :i | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -22,7 +22,7 @@ MaplessMemoryRepositoryTest >> addDummyPeople [ ifTrue: [ guy lastName: guy lastName , i asString ]. guy save ]. 1 to: 10 do: [ :i | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -32,8 +32,8 @@ MaplessMemoryRepositoryTest >> addDummyPeople [ ] { #category : #actions } -MaplessMemoryRepositoryTest >> newDummyPersonNamed: aString [ - ^ DummyPerson new +MaplessMemoryRepositoryTest >> newSamplePersonNamed: aString [ + ^ SamplePerson new firstName: aString; yourself ] @@ -77,16 +77,16 @@ MaplessMemoryRepositoryTest >> testAccessorDatabaseAccess [ { #category : #tests } MaplessMemoryRepositoryTest >> testCursorCount [ repository - do: [ self addDummyPeople. - self assert: DummyPerson count equals: 20 ] + do: [ self addSamplePeople. + self assert: SamplePerson count equals: 20 ] ] { #category : #tests } MaplessMemoryRepositoryTest >> testCursorCountWithConditions [ repository - do: [ self addDummyPeople. + do: [ self addSamplePeople. self - assert: (DummyPerson count: [ :each | each firstName = 'john' ]) + assert: (SamplePerson count: [ :each | each firstName = 'john' ]) equals: 10 + 1 ] ] @@ -101,59 +101,62 @@ MaplessMemoryRepositoryTest >> testDatabaseCollection [ { #category : #tests } MaplessMemoryRepositoryTest >> testDatabaseCollectionFindId [ + | db databaseCollection guy | db := repository database. - databaseCollection := db collectionNamed: 'DummyPerson'. + databaseCollection := db collectionNamed: 'SamplePerson'. self assert: databaseCollection isEmpty. - repository - do: [ guy := DummyPerson new - firstName: 'John'; - lastName: 'Q'; - yourself. - guy save ]. + repository do: [ + guy := SamplePerson new + firstName: 'John'; + lastName: 'Q'; + yourself. + guy save ]. self assert: (databaseCollection includes: guy). - repository - do: [ self assert: (DummyPerson findId: guy id) notNil. - self assert: (DummyPerson findId: guy id) firstName equals: 'John' ] + repository do: [ + self assert: (SamplePerson findId: guy id) notNil. + self assert: (SamplePerson findId: guy id) firstName equals: 'John' ] ] { #category : #tests } MaplessMemoryRepositoryTest >> testDatabaseCollectionFindOneWithConditions [ + | db databaseCollection guys guy | db := repository database. - databaseCollection := db collectionNamed: 'DummyPerson'. + databaseCollection := db collectionNamed: 'SamplePerson'. self assert: databaseCollection isEmpty. - repository - do: [ guys := {'John' . 'Peter' . 'Dave'} - collect: [ :name | (self newDummyPersonNamed: name) save ] ]. - repository - do: [ guy := DummyPerson findOne: [ :each | each firstName = 'Dave' ]. - self assert: guy firstName equals: 'Dave' ] + repository do: [ + guys := { 'John'. 'Peter'. 'Dave' } collect: [ :name | + (self newSamplePersonNamed: name) save ] ]. + repository do: [ + guy := SamplePerson findOne: [ :each | each firstName = 'Dave' ]. + self assert: guy firstName equals: 'Dave' ] ] { #category : #tests } MaplessMemoryRepositoryTest >> testDatabaseCollectionFindWithConditions [ + | db databaseCollection guys guy | db := repository database. - databaseCollection := db collectionNamed: 'DummyPerson'. + databaseCollection := db collectionNamed: 'SamplePerson'. self assert: databaseCollection isEmpty. - repository - do: [ guys := {'John' . 'Peter' . 'Dave'} - collect: [ :name | self newDummyPersonNamed: name ]. - guys do: #save. - guy := DummyPerson find: [ :each | each firstName = 'John' ]. - guys detect: [ :e | e firstName = 'John' ]. - self assert: guys first firstName equals: 'John' ] + repository do: [ + guys := { 'John'. 'Peter'. 'Dave' } collect: [ :name | + self newSamplePersonNamed: name ]. + guys do: #save. + guy := SamplePerson find: [ :each | each firstName = 'John' ]. + guys detect: [ :e | e firstName = 'John' ]. + self assert: guys first firstName equals: 'John' ] ] { #category : #tests } MaplessMemoryRepositoryTest >> testDatabaseCollectionSave [ | db databaseCollection guy | db := repository database. - databaseCollection := db collectionNamed: 'DummyPerson'. + databaseCollection := db collectionNamed: 'SamplePerson'. self assert: databaseCollection isEmpty. repository - do: [ guy := DummyPerson new + do: [ guy := SamplePerson new firstName: 'John'; lastName: 'Q'; yourself. @@ -163,17 +166,18 @@ MaplessMemoryRepositoryTest >> testDatabaseCollectionSave [ { #category : #tests } MaplessMemoryRepositoryTest >> testDatabaseCollectionSaveAndDestroy [ + | db databaseCollection guy | db := repository database. - databaseCollection := db collectionNamed: 'DummyPerson'. - repository - do: [ guy := DummyPerson new - firstName: 'John'; - lastName: 'Q'; - yourself. - guy save. - self assert: (databaseCollection includes: guy). - guy destroy ]. + databaseCollection := db collectionNamed: 'SamplePerson'. + repository do: [ + guy := SamplePerson new + firstName: 'John'; + lastName: 'Q'; + yourself. + guy save. + self assert: (databaseCollection includes: guy). + guy destroy ]. self deny: (databaseCollection includes: guy). self assert: databaseCollection isEmpty ] @@ -194,9 +198,9 @@ MaplessMemoryRepositoryTest >> testDropDatabase [ | db databaseCollection | db := repository database. - repository do: [ self addDummyPeople ]. - databaseCollection := db collectionNamed: 'DummyPerson'. - self assert: databaseCollection name equals: 'DummyPerson'. + repository do: [ self addSamplePeople ]. + databaseCollection := db collectionNamed: 'SamplePerson'. + self assert: databaseCollection name equals: 'SamplePerson'. self deny: repository database collections isEmpty. self shouldnt: [ repository drop ] raise: Error. @@ -208,20 +212,20 @@ MaplessMemoryRepositoryTest >> testExistenceDetection [ | all | repository do: [ - self addDummyPeople. - all := DummyPerson findAll ]. + self addSamplePeople. + all := SamplePerson findAll ]. - self deny: (repository existsId: '123' of: DummyPerson). + self deny: (repository existsId: '123' of: SamplePerson). all do: [ :guy | - self assert: (repository existsId: guy id of: DummyPerson) ] + self assert: (repository existsId: guy id of: SamplePerson) ] ] { #category : #tests } MaplessMemoryRepositoryTest >> testFindAll [ | found | repository - do: [ self addDummyPeople. - found := DummyPerson findAll. + do: [ self addSamplePeople. + found := SamplePerson findAll. self assert: found notNil. self assert: found size equals: 20 ] ] @@ -230,10 +234,10 @@ MaplessMemoryRepositoryTest >> testFindAll [ MaplessMemoryRepositoryTest >> testFindAllSorted [ | found | repository - do: [ (self newDummyPersonNamed: 'Peter') save. - (self newDummyPersonNamed: 'Robert') save. - (self newDummyPersonNamed: 'John') save. - found := DummyPerson findAllSort: #firstName ascending. + do: [ (self newSamplePersonNamed: 'Peter') save. + (self newSamplePersonNamed: 'Robert') save. + (self newSamplePersonNamed: 'John') save. + found := SamplePerson findAllSort: #firstName ascending. self assert: found notNil. self assert: found size equals: 3. self assert: found notNil. @@ -246,12 +250,12 @@ MaplessMemoryRepositoryTest >> testFindManyWithConditionsLimitedAndSorted [ | found | repository do: [ - (self newDummyPersonNamed: 'Peter') save. - (self newDummyPersonNamed: 'Rogers') save. - (self newDummyPersonNamed: 'Robin') save. - (self newDummyPersonNamed: 'Ron') save. - (self newDummyPersonNamed: 'John') save. - found := DummyPerson + (self newSamplePersonNamed: 'Peter') save. + (self newSamplePersonNamed: 'Rogers') save. + (self newSamplePersonNamed: 'Robin') save. + (self newSamplePersonNamed: 'Ron') save. + (self newSamplePersonNamed: 'John') save. + found := SamplePerson find: [ :e | 'Ro*' match: e firstName ] limit: 2 sort: #firstName ascending. @@ -265,23 +269,23 @@ MaplessMemoryRepositoryTest >> testFindManyWithConditionsLimitedAndSorted [ MaplessMemoryRepositoryTest >> testInsert [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. - repository do: [ self assert: DummyPerson findAll isEmpty ]. + repository do: [ self assert: SamplePerson findAll isEmpty ]. repository insert: guy. repository do: [ - self deny: DummyPerson findAll isEmpty. - self assert: DummyPerson findAll size equals: 1 ] + self deny: SamplePerson findAll isEmpty. + self assert: SamplePerson findAll size equals: 1 ] ] { #category : #tests } MaplessMemoryRepositoryTest >> testSelectWithSort [ | found | repository - do: [ self addDummyPeople. - found := DummyPerson + do: [ self addSamplePeople. + found := SamplePerson find: [ :each | each firstName = 'john' | (each firstName = 'john3') ] sort: #firstName ascending. self assert: found notNil. diff --git a/src/Mapless-Memory-Core/MaplessMemoryAccessor.class.st b/src/Mapless-Memory/MaplessMemoryAccessor.class.st similarity index 96% rename from src/Mapless-Memory-Core/MaplessMemoryAccessor.class.st rename to src/Mapless-Memory/MaplessMemoryAccessor.class.st index 7fd8dbc1..29242dee 100644 --- a/src/Mapless-Memory-Core/MaplessMemoryAccessor.class.st +++ b/src/Mapless-Memory/MaplessMemoryAccessor.class.st @@ -7,7 +7,7 @@ Class { #instVars : [ 'databases' ], - #category : #'Mapless-Memory-Core' + #category : #'Mapless-Memory' } { #category : #operations } diff --git a/src/Mapless-Memory-Core/MaplessMemoryCollection.class.st b/src/Mapless-Memory/MaplessMemoryCollection.class.st similarity index 98% rename from src/Mapless-Memory-Core/MaplessMemoryCollection.class.st rename to src/Mapless-Memory/MaplessMemoryCollection.class.st index ca3cc0a1..75802e14 100644 --- a/src/Mapless-Memory-Core/MaplessMemoryCollection.class.st +++ b/src/Mapless-Memory/MaplessMemoryCollection.class.st @@ -8,7 +8,7 @@ Class { 'name', 'elements' ], - #category : #'Mapless-Memory-Core' + #category : #'Mapless-Memory' } { #category : #'instance creation' } diff --git a/src/Mapless-Memory-Core/MaplessMemoryDatabase.class.st b/src/Mapless-Memory/MaplessMemoryDatabase.class.st similarity index 96% rename from src/Mapless-Memory-Core/MaplessMemoryDatabase.class.st rename to src/Mapless-Memory/MaplessMemoryDatabase.class.st index c2ffba5c..b01bbdf4 100644 --- a/src/Mapless-Memory-Core/MaplessMemoryDatabase.class.st +++ b/src/Mapless-Memory/MaplessMemoryDatabase.class.st @@ -8,7 +8,7 @@ Class { 'databaseName', 'collections' ], - #category : #'Mapless-Memory-Core' + #category : #'Mapless-Memory' } { #category : #'instance creation' } diff --git a/src/Mapless-Memory-Core/MaplessMemoryRepository.class.st b/src/Mapless-Memory/MaplessMemoryRepository.class.st similarity index 99% rename from src/Mapless-Memory-Core/MaplessMemoryRepository.class.st rename to src/Mapless-Memory/MaplessMemoryRepository.class.st index a0cc8e86..17ce7a16 100644 --- a/src/Mapless-Memory-Core/MaplessMemoryRepository.class.st +++ b/src/Mapless-Memory/MaplessMemoryRepository.class.st @@ -7,7 +7,7 @@ Class { #instVars : [ 'client' ], - #category : #'Mapless-Memory-Core' + #category : #'Mapless-Memory' } { #category : #actions } diff --git a/src/Mapless-Memory/package.st b/src/Mapless-Memory/package.st new file mode 100644 index 00000000..4c97947d --- /dev/null +++ b/src/Mapless-Memory/package.st @@ -0,0 +1 @@ +Package { #name : #'Mapless-Memory' } diff --git a/src/Mapless-Mongo-Core/MaplessMongoResolver.class.st b/src/Mapless-Mongo-Core/MaplessMongoResolver.class.st deleted file mode 100644 index 91eaafb9..00000000 --- a/src/Mapless-Mongo-Core/MaplessMongoResolver.class.st +++ /dev/null @@ -1,104 +0,0 @@ -" -DEPRECATED (will be removed in the next release) - -I will help the replica set pool to get the clients for read-only and read-write. -I can help to gracefully handle a change of primary in the replica set. -" -Class { - #name : #MaplessMongoResolver, - #superclass : #Object, - #instVars : [ - 'primaryMongoUrl', - 'mongoUrls', - 'secondaryMongoUrls' - ], - #category : #'Mapless-Mongo-Core-Connections' -} - -{ #category : #'instance creation' } -MaplessMongoResolver class >> fromMongoUrls: someMongoUrls [ - ^ self new - initializeOn: someMongoUrls; - yourself -] - -{ #category : #actions } -MaplessMongoResolver >> findPrimaryFor: aMaplessMongoReplicaSetPool [ - "Answers true if the primary was found. - It will create one client to every address configured for the pool and close it after - testing if it's the address of the primary." - - | client | - self mongoUrls - do: [ :mongoUrl | - [ client := aMaplessMongoReplicaSetPool makeClientWith: mongoUrl. - (client notNil and: [ client getIsPrimary ]) - ifTrue: [ self primaryMongoUrl: mongoUrl. - aMaplessMongoReplicaSetPool - triggerEvent: #primaryFound - with: mongoUrl ] ] - ensure: [ client ifNotNil: [ client close ] ] ]. - ^ primaryMongoUrl notNil -] - -{ #category : #accessing } -MaplessMongoResolver >> getPrimaryMongoUrl [ - ^ primaryMongoUrl -] - -{ #category : #accessing } -MaplessMongoResolver >> getSecondaryMongoUrl [ - self secondaryMongoUrls atEnd - ifTrue: [ self secondaryMongoUrls reset ]. - ^ self secondaryMongoUrls next -] - -{ #category : #testing } -MaplessMongoResolver >> hasPrimary [ - ^ primaryMongoUrl notNil -] - -{ #category : #initializing } -MaplessMongoResolver >> initializeOn: someMongoUrls [ - self flag: #deprecated. - "DEPRECATED (this class will be removed in the next release)" - mongoUrls := someMongoUrls -] - -{ #category : #initializing } -MaplessMongoResolver >> initializeSecondaryMongoUrls [ - ^ secondaryMongoUrls := (mongoUrls - reject: [ :each | each = primaryMongoUrl ]) readStream -] - -{ #category : #accessing } -MaplessMongoResolver >> mongoUrls [ - ^ mongoUrls -] - -{ #category : #accessing } -MaplessMongoResolver >> primaryMongoUrl [ - ^ primaryMongoUrl -] - -{ #category : #actions } -MaplessMongoResolver >> primaryMongoUrl: aMongoUrl [ - primaryMongoUrl := aMongoUrl. - self initializeSecondaryMongoUrls -] - -{ #category : #actions } -MaplessMongoResolver >> resetRoles [ - primaryMongoUrl := nil. - secondaryMongoUrls := nil -] - -{ #category : #accessing } -MaplessMongoResolver >> secondaryMongoUrls [ - ^ secondaryMongoUrls ifNil: [ self initializeSecondaryMongoUrls ] -] - -{ #category : #actions } -MaplessMongoResolver >> setPrimary: aMongoUrl [ - primaryMongoUrl := aMongoUrl -] diff --git a/src/Mapless-Mongo-Core/MongoCurrentClient.class.st b/src/Mapless-Mongo-Core/MongoCurrentClient.class.st deleted file mode 100644 index ed3bb8af..00000000 --- a/src/Mapless-Mongo-Core/MongoCurrentClient.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #MongoCurrentClient, - #superclass : #DynamicVariable, - #category : #'Mapless-Mongo-Core-Connections' -} diff --git a/src/Mapless-Mongo-Core/package.st b/src/Mapless-Mongo-Core/package.st deleted file mode 100644 index 070ffb9b..00000000 --- a/src/Mapless-Mongo-Core/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Mapless-Mongo-Core' } diff --git a/src/Mapless-Mongo-ReplicaSet-Tests/MaplessReplicaSetMongoPoolTest.class.st b/src/Mapless-Mongo-ReplicaSet-Tests/MaplessReplicaSetMongoPoolTest.class.st new file mode 100644 index 00000000..d928f192 --- /dev/null +++ b/src/Mapless-Mongo-ReplicaSet-Tests/MaplessReplicaSetMongoPoolTest.class.st @@ -0,0 +1,309 @@ +Class { + #name : #MaplessReplicaSetMongoPoolTest, + #superclass : #MaplessTestCase, + #category : #'Mapless-Mongo-ReplicaSet-Tests' +} + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testCountClientsFromUrl [ + + | pool | + pool := MaplessMongoReplicaSetPool + mongoUrls: { '1@localhost:27017' } + database: 'Mapless-Test'. + + pool idleReadOnlyClients add: + (pool makeClientWith: '1@localhost:27017'). + + self + assert: (pool countClientsTo: 'localhost:27017' asMongoUrl) + equals: 1 +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testDefaults [ + + | pool repository | + pool := MaplessMongoReplicaSetPool + fromString: '1@localhost:27017' + database: 'Mapless-Test'. + + repository := MaplessMongoRepository for: 'Mapless-Test' with: pool. + self + assert: repository accessor minReadWriteClients + equals: MaplessMongoReplicaSetPool defaultMinReadWriteClients. + self + assert: repository accessor maxReadWriteClients + equals: MaplessMongoReplicaSetPool defaultMaxReadWriteClients. + self + assert: repository accessor minReadOnlyClients + equals: MaplessMongoReplicaSetPool defaultMinReadOnlyClients. + self + assert: repository accessor maxReadOnlyClients + equals: MaplessMongoReplicaSetPool defaultMaxReadOnlyClients +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testDeleteConcern [ + + | pool repository | + pool := MaplessMongoReplicaSetPool + fromString: '1@localhost:27017' + database: 'Mapless-Test'. + + repository := MaplessMongoRepository for: 'Mapless-Test' with: pool. + + self deny: repository defaultDeleteConcern notNil. + repository defaultDeleteConcern: #majority. + + self assert: repository defaultDeleteConcern equals: #majority +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testDynamicVariable [ + + self + assert: + MaplessMongoReplicaSetPool local currentClientDynamicVariableClass + equals: MongoCurrentClient +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testGetIdleReadOnlyClient [ + + | pool | + pool := MaplessMongoReplicaSetPool + mongoUrls: { '1@localhost:27017' } + database: 'Mapless-Test'. + + pool idleReadOnlyClients add: + (pool makeClientWith: '1@localhost:27017'). + + self assert: pool getIdleReadOnlyClient class equals: MongoAPI +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testGetIdleReadWriteClient [ + + | pool | + pool := MaplessMongoReplicaSetPool + mongoUrls: { '1@localhost:27017' } + database: 'Mapless-Test'. + + pool idleReadWriteClients add: + (pool makeClientWith: '1@localhost:27017'). + + self assert: pool getIdleReadWriteClient class equals: MongoAPI +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testHasBusyClients [ + + | pool | + pool := MaplessMongoReplicaSetPool + mongoUrls: { '1@localhost:27017' } + database: 'Mapless-Test'. + + pool busyReadOnlyClients add: + (pool makeClientWith: '1@localhost:27017'). + + self assert: pool hasBusyClients. + pool busyReadOnlyClients removeAll. + + pool busyReadWriteClients add: + (pool makeClientWith: '1@localhost:27017'). + + self assert: pool hasBusyClients +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testHasHealthChecker [ + + | pool repository | + pool := MaplessMongoReplicaSetPool + fromString: '1@localhost:27017' + database: 'Mapless-Test'. + + repository := MaplessMongoRepository for: 'Mapless-Test' with: pool. + + self assert: repository accessor hasHealthChecker +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testHasIdleClients [ + + | pool | + pool := MaplessMongoReplicaSetPool + mongoUrls: { '1@localhost:27017' } + database: 'Mapless-Test'. + + pool idleReadOnlyClients add: + (pool makeClientWith: '1@localhost:27017'). + + self assert: pool hasIdleReadOnlyClients. + pool idleReadOnlyClients removeAll. + + pool idleReadWriteClients add: + (pool makeClientWith: '1@localhost:27017'). + + self assert: pool hasIdleReadWriteClients +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testInitializeIsPrimary [ + + | api result | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + + self shouldnt: [ result := api isPrimary ] raise: Error. + self deny: result. + api close +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testInsertConcern [ + + | pool repository | + pool := MaplessMongoReplicaSetPool + fromString: '1@localhost:27017' + database: 'Mapless-Test'. + + repository := MaplessMongoRepository for: 'Mapless-Test' with: pool. + + self deny: repository defaultInsertConcern notNil. + repository defaultInsertConcern: #majority. + + self assert: repository defaultInsertConcern equals: #majority +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testInstanceCreationFromMongoUrls [ + + | pool repository | + pool := MaplessMongoReplicaSetPool + mongoUrls: { '1@localhost:27017' } + database: 'Mapless-Test'. + + repository := MaplessMongoRepository for: 'Mapless-Test' with: pool. + + self + assert: repository accessor resolver mongoUrls first + equals: '1@localhost:27017' asMongoUrl +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testIsPrimary [ + + | api result | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + + self + shouldnt: [ result := api admin isMaster isPrimary ] + raise: Error. + self deny: result. + api close +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testIsReadOnly [ + + | api | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + + self shouldnt: [ api isPrimary ] raise: Error. + self assert: api isReadOnly. + api close +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testIsReadWrite [ + + | api | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + + self shouldnt: [ api isPrimary ] raise: Error. + self deny: api isReadWrite. + api close +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testIsType [ + + | api | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + + self shouldnt: [ api isPrimary ] raise: Error. + + self assert: (api isType: #readOnly). + api close +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testReadConcern [ + + | pool repository | + pool := MaplessMongoReplicaSetPool + fromString: '1@localhost:27017' + database: 'Mapless-Test'. + + repository := MaplessMongoRepository for: 'Mapless-Test' with: pool. + + self deny: repository defaultReadConcern notNil. + repository defaultReadConcern: #majority. + + self assert: repository defaultReadConcern equals: #majority +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testResetRole [ + + | api | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + + self shouldnt: [ api isPrimary ] raise: Error. + + self assert: (api isType: #readOnly). + + self shouldnt: [ api resetIsPrimary ] raise: Error. + self shouldnt: [ api isPrimary ] raise: Error. + self assert: (api isType: #readOnly). + api close +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testUpdateConcern [ + + | pool repository | + pool := MaplessMongoReplicaSetPool + fromString: '1@localhost:27017' + database: 'Mapless-Test'. + + repository := MaplessMongoRepository for: 'Mapless-Test' with: pool. + + self deny: repository defaultUpdateConcern notNil. + repository defaultUpdateConcern: #majority. + + self assert: repository defaultUpdateConcern equals: #majority +] + +{ #category : #tests } +MaplessReplicaSetMongoPoolTest >> testUpsertConcern [ + + | pool repository | + pool := MaplessMongoReplicaSetPool + fromString: '1@localhost:27017' + database: 'Mapless-Test'. + + repository := MaplessMongoRepository for: 'Mapless-Test' with: pool. + + self deny: repository defaultUpsertConcern notNil. + repository defaultUpsertConcern: #majority. + + self assert: repository defaultUpsertConcern equals: #majority +] diff --git a/src/Mapless-Mongo-ReplicaSet-Tests/package.st b/src/Mapless-Mongo-ReplicaSet-Tests/package.st new file mode 100644 index 00000000..29e90eaa --- /dev/null +++ b/src/Mapless-Mongo-ReplicaSet-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'Mapless-Mongo-ReplicaSet-Tests' } diff --git a/src/Mapless-Mongo-Tests/ManifestMaplessMongoTests.class.st b/src/Mapless-Mongo-Tests/ManifestMaplessMongoTests.class.st deleted file mode 100644 index 4b4b003d..00000000 --- a/src/Mapless-Mongo-Tests/ManifestMaplessMongoTests.class.st +++ /dev/null @@ -1,13 +0,0 @@ -" -I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser -" -Class { - #name : #ManifestMaplessMongoTests, - #superclass : #PackageManifest, - #category : #'Mapless-Mongo-Tests-Manifest' -} - -{ #category : #'code-critics' } -ManifestMaplessMongoTests class >> ruleRBSentNotImplementedRuleV1FalsePositive [ - ^ #(#(#(#RGPackageDefinition #(#'Mapless-Mongo-Tests')) #'2021-09-18T00:10:59.943159-03:00') ) -] diff --git a/src/Mapless-Mongo-Tests/MaplessMongoAPITest.class.st b/src/Mapless-Mongo-Tests/MaplessMongoAPITest.class.st new file mode 100644 index 00000000..364f5974 --- /dev/null +++ b/src/Mapless-Mongo-Tests/MaplessMongoAPITest.class.st @@ -0,0 +1,57 @@ +Class { + #name : #MaplessMongoAPITest, + #superclass : #MaplessTestCase, + #category : #'Mapless-Mongo-Tests-Tests' +} + +{ #category : #tests } +MaplessMongoAPITest >> testConnectUsingMongoUrl [ + + | api mongoUrl | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + self assert: api isValid. + api close. + self deny: api isValid. + mongoUrl := ZnUrl fromString: 'mongodb://localhost:27017'. + self assert: api asMongoUrl equals: mongoUrl. + + self assert: (api isAt: mongoUrl) +] + +{ #category : #tests } +MaplessMongoAPITest >> testGetAdminDatabase [ + + | api | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + + self assert: api admin class equals: MongoDatabase. + api close +] + +{ #category : #tests } +MaplessMongoAPITest >> testGetCollection [ + + | repository | + repository := MaplessMongoRepository + for: 'Mapless-Test' + with: MaplessStandaloneMongoPool local. + + repository do: [ + self assert: SamplePerson collection class equals: MongoCollection. + self + assert: SamplePerson collection name + equals: SamplePerson collectionName ] +] + +{ #category : #tests } +MaplessMongoAPITest >> testGetMongoInfo [ + + | api | + api := MongoAPI mongoUrl: 'mongodb://localhost:27017/Mapless-Test'. + api open. + + self assert: api admin isMaster class equals: MongoIsMaster. + api close +] diff --git a/src/Mapless-Mongo-Tests/MaplessMongoModelTest.class.st b/src/Mapless-Mongo-Tests/MaplessMongoModelTest.class.st index a7a4756f..1d4493c6 100644 --- a/src/Mapless-Mongo-Tests/MaplessMongoModelTest.class.st +++ b/src/Mapless-Mongo-Tests/MaplessMongoModelTest.class.st @@ -36,7 +36,7 @@ MaplessMongoModelTest >> tearDown [ { #category : #tests } MaplessMongoModelTest >> testDeleteHook [ | user | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. self assert: user beforeDelete isNil. @@ -52,7 +52,7 @@ MaplessMongoModelTest >> testDeleteHook [ { #category : #tests } MaplessMongoModelTest >> testDestroyHook [ | user | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. self assert: user beforeDestroy isNil. @@ -66,7 +66,7 @@ MaplessMongoModelTest >> testDestroyHook [ { #category : #tests } MaplessMongoModelTest >> testInsertHook [ | user | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. self assert: user beforeInsert isNil. @@ -80,17 +80,17 @@ MaplessMongoModelTest >> testInsertHook [ MaplessMongoModelTest >> testMergeComposed [ | user guy newerUser newerGuy | self - do: [ user := DummyUser new + do: [ user := SampleUser new username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'John'; yourself. user person: guy. - newerUser := DummyUser new + newerUser := SampleUser new email: 'johnq@email'; yourself. - newerGuy := DummyPerson new + newerGuy := SamplePerson new firstName: 'JohM'; lastName: 'Q'; yourself. @@ -107,10 +107,10 @@ MaplessMongoModelTest >> testMergeComposed [ { #category : #tests } MaplessMongoModelTest >> testMergeSimple [ | user newerUser | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. - newerUser := DummyUser new + newerUser := SampleUser new email: 'johnq@email'; yourself. self assert: user email isNil. @@ -124,7 +124,7 @@ MaplessMongoModelTest >> testMergeSimple [ { #category : #tests } MaplessMongoModelTest >> testRaiseErrorWhenTryingToInsertADuplicatedUnique [ | user | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. self @@ -141,17 +141,17 @@ MaplessMongoModelTest >> testRaiseErrorWhenTryingToSaveADuplicatedUnique [ repository do: [ repository database command: - {('createIndexes' -> DummyPerson collectionName). + {('createIndexes' -> SamplePerson collectionName). ('indexes' -> {{('key' -> {('lastName' -> 1)} asDictionary). ('name' -> 'lastName_unique'). ('unique' -> true)} asDictionary})} asOrderedDictionary ]. - john := DummyPerson new + john := SamplePerson new firstName: 'John'; lastName: 'Someson'; yourself. - peter := DummyPerson new + peter := SamplePerson new firstName: 'Peter'; lastName: 'Someson'; yourself. @@ -169,7 +169,7 @@ MaplessMongoModelTest >> testRaiseErrorWhenTryingToSaveADuplicatedUnique [ { #category : #tests } MaplessMongoModelTest >> testSaveHook [ | user | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. self assert: user beforeSave isNil. @@ -187,15 +187,15 @@ MaplessMongoModelTest >> testUnrefDestroy [ self do: [ tagsCollection := OrderedCollection new add: - (DummyTag new + (SampleTag new isCustomer: true; yourself); add: - (DummyTag new + (SampleTag new isComplicated: false; yourself); yourself. - person := DummyPerson new + person := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -204,7 +204,7 @@ MaplessMongoModelTest >> testUnrefDestroy [ "save tagsCollection" tagsCollection do: [ :e | e save ]. person save. - loaded := DummyPerson findId: person id. + loaded := SamplePerson findId: person id. self assert: loaded notNil. reified := loaded unreferenced. self assert: reified maplessData tags class = OrderedCollection. @@ -216,7 +216,7 @@ MaplessMongoModelTest >> testUnrefDestroy [ self assert: reified maplessData tags second isComplicated = false. reified destroy. "loaded destroy" - self assert: (reloaded := DummyPerson existsId: reified id) not ] + self assert: (reloaded := SamplePerson existsId: reified id) not ] ] { #category : #tests } @@ -225,27 +225,27 @@ MaplessMongoModelTest >> testUnrefDestroy2 [ self do: [ friends := OrderedCollection new add: - (DummyPerson new + (SamplePerson new firstName: 'Frodo'; yourself); add: - (DummyPerson new + (SamplePerson new firstName: 'Gandalf'; yourself); add: - (DummyPerson new + (SamplePerson new firstName: 'Boromir'; yourself); yourself. stuff := #('Ice cream' 'waffles' 'french fries'). - guy := DummyPerson new + guy := SamplePerson new firstName: 'dude'; favorites: stuff; friends: friends; yourself. self do: [ friends do: [ :e | e save ] ]. self do: [ guy save ]. - self do: [ loaded := DummyPerson findId: guy id ]. + self do: [ loaded := SamplePerson findId: guy id ]. self assert: loaded notNil. self do: [ reified := loaded unreferenced ]. self assert: reified data friends class = OrderedCollection. @@ -254,12 +254,12 @@ MaplessMongoModelTest >> testUnrefDestroy2 [ "By design, the destruction should be to the individual aggregate (and not its submodels). It's programmers' responsability to decide when to destroy a sub aggregate" self - assert: (self do: [ reloaded := DummyPerson existsId: loaded id ]) not. + assert: (self do: [ reloaded := SamplePerson existsId: loaded id ]) not. self do: [ self assert: ((friends collect: [ :e | e id ]) - allSatisfy: [ :guyId | DummyPerson existsId: guyId ]) ] ] + allSatisfy: [ :guyId | SamplePerson existsId: guyId ]) ] ] ] { #category : #tests } @@ -270,15 +270,15 @@ MaplessMongoModelTest >> testUnreferenced [ self do: [ tagsCollection := OrderedCollection new add: - (DummyTag new + (SampleTag new isCustomer: true; yourself); add: - (DummyTag new + (SampleTag new isComplicated: false; yourself); yourself. - person := DummyPerson new + person := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -288,7 +288,7 @@ MaplessMongoModelTest >> testUnreferenced [ "save tagsCollection" tagsCollection do: [ :e | self do: [ e save ] ]. self do: [ person save ]. - self do: [ loaded := DummyPerson findId: person id ]. + self do: [ loaded := SamplePerson findId: person id ]. self assert: loaded notNil. self do: [ reified := loaded unreferenced ]. self assert: reified data tags class = OrderedCollection. @@ -305,28 +305,28 @@ MaplessMongoModelTest >> testUnreferenced2 [ self do: [ friends := OrderedCollection new add: - (DummyPerson new + (SamplePerson new firstName: 'Frodo'; yourself); add: - (DummyPerson new + (SamplePerson new firstName: 'Gandalf'; yourself); add: - (DummyPerson new + (SamplePerson new firstName: 'Boromir'; yourself); yourself. stuff := #('Ice cream' 'waffles' 'french fries') asOrderedCollection. - guy := DummyPerson new + guy := SamplePerson new firstName: 'dude'; favorites: stuff; friends: friends; yourself. friends do: [ :e | self do: [ e save ] ]. self do: [ guy save ]. - self do: [ loaded := DummyPerson findId: guy id ]. + self do: [ loaded := SamplePerson findId: guy id ]. self assert: loaded notNil. self do: [ reified := loaded unreferenced ]. self assert: reified data friends class = OrderedCollection. @@ -336,7 +336,7 @@ MaplessMongoModelTest >> testUnreferenced2 [ { #category : #tests } MaplessMongoModelTest >> testUpdatetHook [ | user | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. self assert: user beforeUpdate isNil. @@ -351,7 +351,7 @@ MaplessMongoModelTest >> testUpdatetHook [ { #category : #tests } MaplessMongoModelTest >> testUpsertHook [ | user | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. self assert: user beforeUpsert isNil. @@ -364,7 +364,7 @@ MaplessMongoModelTest >> testUpsertHook [ { #category : #tests } MaplessMongoModelTest >> testUpsertHookOnSave [ | user | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. self assert: user beforeUpsert isNil. diff --git a/src/Mapless-Mongo-Tests/MaplessMongoMultiRepositoryTest.class.st b/src/Mapless-Mongo-Tests/MaplessMongoMultiRepositoryTest.class.st index 0763d580..e79ea362 100644 --- a/src/Mapless-Mongo-Tests/MaplessMongoMultiRepositoryTest.class.st +++ b/src/Mapless-Mongo-Tests/MaplessMongoMultiRepositoryTest.class.st @@ -48,21 +48,21 @@ MaplessMongoMultiRepositoryTest >> testSaveToAndReadFromTwoDatabases [ repositories at: 1 put: repo1. repositories at: 2 put: repo2. repo1 - do: [ guy := DummyPerson new + do: [ guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. guy save. - found := DummyPerson findId: guy id. + found := SamplePerson findId: guy id. self assert: found notNil. self assert: found firstName equals: guy firstName ]. repo2 - do: [ guy := DummyPerson new + do: [ guy := SamplePerson new firstName: 'peter'; lastName: 'e'; yourself. guy save. - found := DummyPerson findId: guy id. + found := SamplePerson findId: guy id. self assert: found notNil. self assert: found firstName equals: guy firstName ] ] diff --git a/src/Mapless-Mongo-Tests/MaplessMongoQueriesTest.class.st b/src/Mapless-Mongo-Tests/MaplessMongoQueriesTest.class.st index b17075c1..cec2babc 100644 --- a/src/Mapless-Mongo-Tests/MaplessMongoQueriesTest.class.st +++ b/src/Mapless-Mongo-Tests/MaplessMongoQueriesTest.class.st @@ -8,10 +8,10 @@ Class { } { #category : #tests } -MaplessMongoQueriesTest >> addDummyPeople [ +MaplessMongoQueriesTest >> addSamplePeople [ | guy | 1 to: 10 do: [ :i | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -19,7 +19,7 @@ MaplessMongoQueriesTest >> addDummyPeople [ ifTrue: [ guy lastName: guy lastName , i asString ]. guy save ]. 1 to: 10 do: [ :i | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -47,28 +47,28 @@ MaplessMongoQueriesTest >> tearDown [ { #category : #tests } MaplessMongoQueriesTest >> testCursorCount [ repository - do: [ self addDummyPeople. - self assert: DummyPerson count equals: DummyPerson findAll size ] + do: [ self addSamplePeople. + self assert: SamplePerson count equals: SamplePerson findAll size ] ] { #category : #tests } MaplessMongoQueriesTest >> testCursorCountWithConditions [ repository - do: [ self addDummyPeople. + do: [ self addSamplePeople. self - assert: (DummyPerson count: {('firstName' -> 'john')} asDictionary) + assert: (SamplePerson count: {('firstName' -> 'john')} asDictionary) equals: 10 + 1. self - deny: (DummyPerson count: {('firstName' -> 'john')} asDictionary) - equals: DummyPerson findAll size ] + deny: (SamplePerson count: {('firstName' -> 'john')} asDictionary) + equals: SamplePerson findAll size ] ] { #category : #tests } MaplessMongoQueriesTest >> testFindAll [ | found | repository - do: [ self addDummyPeople. - found := DummyPerson findAll. + do: [ self addSamplePeople. + found := SamplePerson findAll. self assert: found notNil. self assert: found size equals: 20 ] ] @@ -77,8 +77,8 @@ MaplessMongoQueriesTest >> testFindAll [ MaplessMongoQueriesTest >> testFresh [ | found guy freshGuy | repository - do: [ self addDummyPeople. - found := DummyPerson findAll. + do: [ self addSamplePeople. + found := SamplePerson findAll. self assert: found notNil. self assert: found size equals: 20 ]. guy := found first. @@ -96,8 +96,8 @@ MaplessMongoQueriesTest >> testFresh [ MaplessMongoQueriesTest >> testSelectWithAnd [ | found | repository - do: [ self addDummyPeople. - found := DummyPerson + do: [ self addSamplePeople. + found := SamplePerson find: [ :each | each firstName = 'john' & (each lastName = 'q4') ]. self assert: found notEmpty. self assert: found size equals: 1. @@ -109,8 +109,8 @@ MaplessMongoQueriesTest >> testSelectWithAnd [ MaplessMongoQueriesTest >> testSelectWithOr [ | found | repository - do: [ self addDummyPeople. - found := DummyPerson + do: [ self addSamplePeople. + found := SamplePerson find: [ :each | each firstName = 'john' | (each firstName = 'john3') ]. self assert: found notNil. self assert: found size equals: 1 + 10 + 1. @@ -122,8 +122,8 @@ MaplessMongoQueriesTest >> testSelectWithOr [ MaplessMongoQueriesTest >> testSelectWithSort [ | found | repository - do: [ self addDummyPeople. - found := DummyPerson + do: [ self addSamplePeople. + found := SamplePerson find: [ :each | each firstName = 'john' | (each firstName = 'john3') ] sort: {('firstName' -> 1)} asDictionary. self assert: found notNil. diff --git a/src/Mapless-Mongo-Tests/MaplessMongoTest.class.st b/src/Mapless-Mongo-Tests/MaplessMongoTest.class.st index 189fe1e8..87ea1ec8 100644 --- a/src/Mapless-Mongo-Tests/MaplessMongoTest.class.st +++ b/src/Mapless-Mongo-Tests/MaplessMongoTest.class.st @@ -38,13 +38,6 @@ MaplessMongoTest >> do: aBlock [ ^ repository do: aBlock ] -{ #category : #tests } -MaplessMongoTest >> newDummyPersonNamed: aString [ - ^ DummyPerson new - firstName: aString; - yourself -] - { #category : #actions } MaplessMongoTest >> newRepository [ ^ MaplessMongoRepository @@ -52,6 +45,13 @@ MaplessMongoTest >> newRepository [ with: MaplessStandaloneMongoPool local ] +{ #category : #tests } +MaplessMongoTest >> newSamplePersonNamed: aString [ + ^ SamplePerson new + firstName: aString; + yourself +] + { #category : #'setUp-tearDown' } MaplessMongoTest >> setUp [ super setUp. @@ -67,16 +67,44 @@ MaplessMongoTest >> tearDown [ shutDown ] +{ #category : #tests } +MaplessMongoTest >> testAfterDestroyed [ + + | guy | + guy := SamplePerson new + firstName: 'john'; + lastName: 'q'; + yourself. + self assert: guy recentlyDestroyed isNil. + self do: [ guy save ]. + self assert: guy recentlySaved. + self do: [ guy destroy ]. + self assert: guy recentlyDestroyed +] + +{ #category : #tests } +MaplessMongoTest >> testAfterSaved [ + + | guy | + guy := SamplePerson new + firstName: 'john'; + lastName: 'q'; + yourself. + self assert: guy recentlySaved isNil. + self do: [ guy save ]. + self assert: guy recentlySaved +] + { #category : #tests } MaplessMongoTest >> testComposedAccess [ "Test proxies and its on-demand-load and DNU mechanism" | user guy | repository - readWriteDo: [ user := DummyUser new + readWriteDo: [ user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -87,19 +115,19 @@ MaplessMongoTest >> testComposedAccess [ readOnlyDo: [ self waitABit. self - assert: (DummyUser findId: user id) completeName + assert: (SampleUser findId: user id) completeName equals: 'john q'. self - assert: (DummyUser findId: user id) person class + assert: (SampleUser findId: user id) person class equals: MaplessReference. self - assert: (DummyUser findId: user id) person model class - equals: DummyPerson. + assert: (SampleUser findId: user id) person model class + equals: SamplePerson. self - assert: (DummyUser findId: user id) person firstName + assert: (SampleUser findId: user id) person firstName equals: 'john'. self - assert: (DummyUser findId: user id) person lastName + assert: (SampleUser findId: user id) person lastName equals: 'q' ] ] @@ -112,10 +140,10 @@ MaplessMongoTest >> testComposedDelete [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -141,10 +169,10 @@ MaplessMongoTest >> testComposedDestroy [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -154,22 +182,22 @@ MaplessMongoTest >> testComposedDestroy [ self assert: (users - allSatisfy: [ :user | (DummyPerson existsId: user person id) not ]). + allSatisfy: [ :user | (SamplePerson existsId: user person id) not ]). self - assert: (users allSatisfy: [ :user | DummyUser existsId: user id ]). + assert: (users allSatisfy: [ :user | SampleUser existsId: user id ]). users do: [ :user | user destroy ]. self - assert: (users allSatisfy: [ :user | (DummyUser existsId: user id) not ]) ] + assert: (users allSatisfy: [ :user | (SampleUser existsId: user id) not ]) ] ] { #category : #tests } MaplessMongoTest >> testComposedResaveAndLoad [ | user guy loaded | repository - readWriteDo: [ user := DummyUser new + readWriteDo: [ user := SampleUser new username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'John'; lastName: 'W'; yourself. @@ -179,13 +207,13 @@ MaplessMongoTest >> testComposedResaveAndLoad [ repository readOnlyDo: [ self waitABit. - loaded := DummyUser findId: user id. + loaded := SampleUser findId: user id. self assert: loaded person firstName equals: 'John'. loaded person lastName: 'wayne'. loaded person save. - loaded := DummyUser findId: user id. + loaded := SampleUser findId: user id. self assert: loaded person lastName equals: 'wayne'. - loaded := DummyUser findId: user id. + loaded := SampleUser findId: user id. self assert: loaded person firstName equals: 'John' ]. repository readWriteDo: [ loaded person lastName: 'Wayne'. @@ -193,7 +221,7 @@ MaplessMongoTest >> testComposedResaveAndLoad [ loaded username: 'johnw'. loaded save ]. repository - readOnlyDo: [ loaded := DummyUser findId: user id. + readOnlyDo: [ loaded := SampleUser findId: user id. self assert: loaded username equals: 'johnw'. self assert: loaded person firstName equals: 'John' ] ] @@ -202,10 +230,10 @@ MaplessMongoTest >> testComposedResaveAndLoad [ MaplessMongoTest >> testComposedSave [ | user guy | self - do: [ user := DummyUser new + do: [ user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -223,11 +251,11 @@ MaplessMongoTest >> testComposedSave [ MaplessMongoTest >> testComposedSaveAndLoad [ | user guy loaded | repository - readWriteDo: [ user := DummyUser new + readWriteDo: [ user := SampleUser new createdOn: DateAndTime now; username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new createdOn: DateAndTime now; firstName: 'john'; lastName: 'q'; @@ -242,16 +270,16 @@ MaplessMongoTest >> testComposedSaveAndLoad [ MaplessMongoTest >> testComposition [ | user guy | self - do: [ user := DummyUser new + do: [ user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. - self assert: (user data at: 'person') class equals: DummyPerson. - self assert: (user data at: 'person') _c equals: #DummyPerson. + self assert: (user data at: 'person') class equals: SamplePerson. + self assert: (user data at: 'person') _c equals: #SamplePerson. self assert: user id isNil. self assert: (user data at: 'person') id isNil. self assert: user completeName equals: 'john q' ] @@ -261,7 +289,7 @@ MaplessMongoTest >> testComposition [ MaplessMongoTest >> testDateAndTime [ | when guy loaded | when := DateAndTime now asUTC. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; createdOn: when; @@ -269,7 +297,7 @@ MaplessMongoTest >> testDateAndTime [ repository save: guy. repository readOnlyDo: [ self waitABit. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded createdOn asDate asString = when asDate asString. self assert: loaded createdOn asTime hour = when asTime hour. @@ -286,7 +314,7 @@ MaplessMongoTest >> testDelete [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | guy save ]. @@ -304,27 +332,63 @@ MaplessMongoTest >> testDestroy [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | guy save ]. self assert: (people allSatisfy: [ :guy | guy isDeleted not ]). people do: [ :guy | guy destroy ]. self - assert: (people allSatisfy: [ :guy | (DummyPerson existsId: guy id) not ]) ] + assert: (people allSatisfy: [ :guy | (SamplePerson existsId: guy id) not ]) ] +] + +{ #category : #tests } +MaplessMongoTest >> testDestroyAll [ + | people | + self + do: [ people := OrderedCollection new. + Character alphabet + do: [ :char | + people + add: + (SamplePerson new + firstName: char asString; + yourself) ]. + people do: [ :guy | guy save ]. + self assert: (people allSatisfy: [ :guy | guy isDeleted not ]). + SamplePerson getRepository destroyAll: SamplePerson. + + self + assert: (people allSatisfy: [ :guy | (SamplePerson existsId: guy id) not ]) ] +] + +{ #category : #tests } +MaplessMongoTest >> testDestroyById [ + + | guy | + self do: [ + guy := SampleUser new + userame: 'johnq'; + save ]. + self do: [ self assert: (SampleUser existsId: guy id) ]. + self + shouldnt: [ repository destroyOne: SampleUser atId: guy id ] + raise: Error. + + self do: [ self deny: (SampleUser existsId: guy id) ] ] { #category : #tests } MaplessMongoTest >> testFindAll [ | found | repository - readWriteDo: [ (self newDummyPersonNamed: 'Peter') save. - (self newDummyPersonNamed: 'Robert') save. - (self newDummyPersonNamed: 'John') save ]. + readWriteDo: [ (self newSamplePersonNamed: 'Peter') save. + (self newSamplePersonNamed: 'Robert') save. + (self newSamplePersonNamed: 'John') save ]. repository readOnlyDo: [ self waitABit. - found := DummyPerson findAll. + found := SamplePerson findAll. self assert: found notNil. self assert: found size equals: 3 ] ] @@ -333,13 +397,13 @@ MaplessMongoTest >> testFindAll [ MaplessMongoTest >> testFindAllSorted [ | found | repository - readWriteDo: [ (self newDummyPersonNamed: 'Peter') save. - (self newDummyPersonNamed: 'Robert') save. - (self newDummyPersonNamed: 'John') save ]. + readWriteDo: [ (self newSamplePersonNamed: 'Peter') save. + (self newSamplePersonNamed: 'Robert') save. + (self newSamplePersonNamed: 'John') save ]. repository readOnlyDo: [ self waitABit. - found := DummyPerson findAllSort: {(#firstName -> 1)} asDictionary. + found := SamplePerson findAllSort: {(#firstName -> 1)} asDictionary. self assert: found notNil. self assert: found size equals: 3. self assert: found notNil. @@ -347,16 +411,50 @@ MaplessMongoTest >> testFindAllSorted [ self assert: found last firstName = 'Robert' ] ] +{ #category : #tests } +MaplessMongoTest >> testFirst [ + + | found | + repository readWriteDo: [ (self newSamplePersonNamed: 'Peter') save ]. + repository readOnlyDo: [ + self waitABit. + found := SamplePerson first. + self assert: found notNil. + self assert: found firstName equals: 'Peter' ] +] + { #category : #tests } MaplessMongoTest >> testIsUnsaved [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. self do: [ guy save ] ] +{ #category : #tests } +MaplessMongoTest >> testMaplessClass [ + + | user guy reference | + self do: [ + user := SampleUser new + userame: 'johnq'; + yourself. + guy := SamplePerson new + firstName: 'john'; + lastName: 'q'; + yourself. + user person: guy. + + guy save. + user save. + self assert: SamplePerson maplessClass equals: SamplePerson. + reference := SampleUser first person. + self assert: reference class equals: MaplessReference. + self assert: reference maplessClass equals: SamplePerson ] +] + { #category : #tests } MaplessMongoTest >> testMultipleComposedComposables [ | tags tagsOfTags tagsOfTagsOfTags loaded | @@ -366,35 +464,35 @@ MaplessMongoTest >> testMultipleComposedComposables [ tagsOfTagsOfTags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'is this'; yourself); add: - (DummyTag new + (SampleTag new label: 'multiply'; yourself); add: - (DummyTag new + (SampleTag new label: 'composable?'; yourself); yourself. tagsOfTags add: - (DummyTag new + (SampleTag new label: 'like'; yourself); add: - (DummyTag new + (SampleTag new label: 'really?'; yourself); yourself. tagsOfTagsOfTags add: - (DummyTag new + (SampleTag new label: 'wow'; yourself); add: - (DummyTag new + (SampleTag new label: 'nice'; yourself); yourself. @@ -410,7 +508,7 @@ MaplessMongoTest >> testMultipleComposedComposables [ self shouldnt: [ self do: [ tags do: [ :e | e save ] ] ] raise: MaplessUnsavedSubmodel. - loaded := DummyTag findId: tags first id. + loaded := SampleTag findId: tags first id. self assert: loaded notNil. self assert: loaded label = 'is this'. self assert: loaded tags isCollection. @@ -430,22 +528,22 @@ MaplessMongoTest >> testMultipleComposedComposables [ MaplessMongoTest >> testMultipleComposedMixedSaveAndLoad [ | guy things loaded | repository - readWriteDo: [ guy := DummyPerson new + readWriteDo: [ guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. guy things: OrderedCollection new. guy things add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); add: - (DummyUser new + (SampleUser new info: 'also this'; yourself); yourself. @@ -456,7 +554,7 @@ MaplessMongoTest >> testMultipleComposedMixedSaveAndLoad [ raise: MaplessUnsavedSubmodel ]. repository readOnlyDo: [ self waitABit. - loaded := DummyPerson findId: guy id. + loaded := SamplePerson findId: guy id. self assert: loaded notNil. self assert: loaded firstName = 'john'. self assert: loaded things isCollection. @@ -464,30 +562,30 @@ MaplessMongoTest >> testMultipleComposedMixedSaveAndLoad [ loaded things do: [ :each | self assert: (things anySatisfy: [ :t | t id = each id ]) ]. loaded unreferenced. - self assert: loaded things first class = DummyTag. - self assert: loaded things second class = DummyTag. - self assert: loaded things third class = DummyUser ] + self assert: loaded things first class = SampleTag. + self assert: loaded things second class = SampleTag. + self assert: loaded things third class = SampleUser ] ] { #category : #tests } MaplessMongoTest >> testMultipleComposedSaveAndLoad [ | user guy tags loaded | repository - readWriteDo: [ user := DummyUser new + readWriteDo: [ user := SampleUser new username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. tags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); yourself. @@ -500,7 +598,7 @@ MaplessMongoTest >> testMultipleComposedSaveAndLoad [ self shouldnt: [ user save ] raise: MaplessUnsavedSubmodel ]. repository readOnlyDo: [ self waitABit. - loaded := DummyUser findId: user id. + loaded := SampleUser findId: user id. self assert: loaded notNil. self assert: loaded username = 'johnq'. self assert: loaded tags isCollection. @@ -510,6 +608,56 @@ MaplessMongoTest >> testMultipleComposedSaveAndLoad [ do: [ :tag | self assert: (tags anySatisfy: [ :t | t id = tag id ]) ] ] ] +{ #category : #tests } +MaplessMongoTest >> testQueryConditionally [ + + | users found | + self do: [ + users := OrderedCollection new. + Character alphabet do: [ :char | + SampleUser new + username: char asString; + person: (SamplePerson new + firstName: char asString; + save); + save ] ]. + + self do: [ + found := SampleUser + find: { ('username' -> 'j') } asDictionary + limit: 1 ]. + self assert: found notNil. + self assert: found notEmpty. + self assert: found first username equals: 'j' +] + +{ #category : #tests } +MaplessMongoTest >> testQueryConditionallySorted [ + + | users found | + self do: [ + users := OrderedCollection new. + Character alphabet do: [ :char | + SampleUser new + username: char asString; + person: (SamplePerson new + firstName: char asString; + save); + save ] ]. + + self do: [ + found := SampleUser + find: { ('$or' -> { + { (#username -> 'j') } asDictionary. + { (#username -> 'z') } asDictionary }) } asDictionary + sort: { (#username -> 1) } asDictionary ]. + self assert: found notNil. + self assert: found notEmpty. + self assert: found size equals: 2. + self assert: found first username equals: 'j'. + self assert: found second username equals: 'z' +] + { #category : #tests } MaplessMongoTest >> testQueryUsers [ | users | @@ -519,10 +667,10 @@ MaplessMongoTest >> testQueryUsers [ do: [ :char | users add: - (DummyUser new + (SampleUser new username: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -532,13 +680,13 @@ MaplessMongoTest >> testQueryUsers [ do: [ self assert: (Character alphabet - allSatisfy: [ :char | (DummyUser findUsername: char asString) notNil ]) ] ] + allSatisfy: [ :char | (SampleUser findUsername: char asString) notNil ]) ] ] ] { #category : #tests } MaplessMongoTest >> testSaveSetsID [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -550,25 +698,29 @@ MaplessMongoTest >> testSaveSetsID [ { #category : #tests } MaplessMongoTest >> testSimpleSave [ + | guy | - guy := DummyPerson new - firstName: 'john'; - lastName: 'q'; - yourself. - self do: [ guy save ] + guy := SamplePerson new + firstName: 'john'; + lastName: 'q'; + yourself. + self do: [ guy save ]. + + self assert: guy isMapless. + self assert: guy recentlySaved ] { #category : #tests } MaplessMongoTest >> testSimpleSaveAndLoad [ | guy loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository readWriteDo: [ guy save ]. repository readOnlyDo: [ self waitABit. - loaded := DummyPerson findId: guy id ]. + loaded := SamplePerson findId: guy id ]. self assert: loaded notNil. loaded data keysAndValuesDo: [ :k :v | @@ -580,28 +732,28 @@ MaplessMongoTest >> testSimpleSaveAndLoad [ MaplessMongoTest >> testSimpleSaveAndUpdate [ | guy loaded reloaded | repository - readWriteDo: [ guy := DummyPerson new + readWriteDo: [ guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. guy save ]. repository readOnlyDo: [ self waitABit. - loaded := DummyPerson findId: guy id. + loaded := SamplePerson findId: guy id. self assert: loaded firstName equals: 'john'. self deny: loaded remember equals: 'this words' ]. loaded remember: 'this words'. repository readWriteDo: [ loaded save. - reloaded := repository findOne: DummyPerson atId: guy id. + reloaded := repository findOne: SamplePerson atId: guy id. self assert: reloaded remember = 'this words' ] ] { #category : #tests } MaplessMongoTest >> testSimpleSaveWithAByteSymbol [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; value: #thisByteSymbol; @@ -612,25 +764,25 @@ MaplessMongoTest >> testSimpleSaveWithAByteSymbol [ { #category : #tests } MaplessMongoTest >> testSubModelsFromReifiedJSON [ | user guy jsonString reified | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. self do: [ jsonString := user unreferenced asJSONString. - reified := DummyUser fromJSONString: jsonString ]. - self assert: reified person class equals: DummyPerson. + reified := SampleUser fromJSONString: jsonString ]. + self assert: reified person class equals: SamplePerson. self assert: reified completeName equals: 'john q' ] { #category : #tests } MaplessMongoTest >> testUpsert [ | guy theId found freshFound | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -639,16 +791,52 @@ MaplessMongoTest >> testUpsert [ theId := guy id ]. repository readOnlyDo: [ self waitABit. - found := DummyPerson findId: theId. + found := SamplePerson findId: theId. self assert: found notNil equals: true. self assert: found firstName equals: 'john'. found firstName: 'John'. found upsert ]. repository - readOnlyDo: [ freshFound := DummyPerson findId: theId. + readOnlyDo: [ freshFound := SamplePerson findId: theId. self assert: freshFound firstName equals: 'John' ] ] +{ #category : #tests } +MaplessMongoTest >> testWithClientDo [ + + self + shouldnt: [ + repository withClientDo: [ :client | + SampleUser new + userame: 'johnq'; + save ] ] + raise: Error +] + +{ #category : #tests } +MaplessMongoTest >> testWithReadOnlyClientDo [ + + self + shouldnt: [ + repository withReadOnlyClientDo: [ :client | + SampleUser new + userame: 'johnq'; + save ] ] + raise: Error +] + +{ #category : #tests } +MaplessMongoTest >> testWithReadWriteClientDo [ + + self + shouldnt: [ + repository withReadWriteClientDo: [ :client | + SampleUser new + userame: 'johnq'; + save ] ] + raise: Error +] + { #category : #actions } MaplessMongoTest >> waitABit [ 10 milliSeconds asDelay wait diff --git a/src/Mapless-Mongo-Tests/MaplessResolversTest.class.st b/src/Mapless-Mongo-Tests/MaplessResolversTest.class.st new file mode 100644 index 00000000..f799824a --- /dev/null +++ b/src/Mapless-Mongo-Tests/MaplessResolversTest.class.st @@ -0,0 +1,148 @@ +Class { + #name : #MaplessResolversTest, + #superclass : #MaplessTestCase, + #instVars : [ + 'repository' + ], + #category : #'Mapless-Mongo-Tests-Tests' +} + +{ #category : #running } +MaplessResolversTest >> setUp [ + + super setUp. + repository := MaplessMongoRepository + for: 'Mapless-Test' + with: MaplessStandaloneMongoPool local +] + +{ #category : #running } +MaplessResolversTest >> tearDown [ + super tearDown. + repository + drop; + shutDown +] + +{ #category : #tests } +MaplessResolversTest >> testCanRepresentArrayOfMaplessReferences [ + + self assert: (repository resolver + canRepresentArrayOfMaplessReferences: { + { + ('_c' -> 'SampleUser'). + ('_id' -> '12') } asDictionary. + { + ('_c' -> 'SamplePerson'). + ('_id' -> '123') } asDictionary } + in: repository) +] + +{ #category : #tests } +MaplessResolversTest >> testCanRepresentSubMapless [ + + self assert: (repository resolver + canRepresentSubMapless: { + ('_c' -> 'SamplePerson'). + ('_id' -> '123') } asDictionary + in: repository) +] + +{ #category : #tests } +MaplessResolversTest >> testConditionForClass [ + + self + assert: (repository resolver conditionForClass: SamplePerson) + equals: { ('_c' -> 'SamplePerson') } asDictionary +] + +{ #category : #tests } +MaplessResolversTest >> testMaplessAsStorable [ + + | saved | + saved := SamplePerson new. + repository save: saved. + + self + assert: + (repository resolver maplessAsStorable: saved in: repository) + asDictionary + equals: { + ('_c' -> 'SamplePerson'). + ('_id' -> saved id) } asDictionary +] + +{ #category : #tests } +MaplessResolversTest >> testMaplessClass [ + + self + assert: (repository resolver + maplessClassFor: { ('_c' -> 'SamplePerson') } asDictionary + in: repository) + equals: SamplePerson +] + +{ #category : #tests } +MaplessResolversTest >> testMaplessClassNameFor [ + + self + assert: (repository resolver + maplessClassNameFor: { + ('_c' -> 'SamplePerson'). + ('_id' -> '123') } asDictionary + in: repository) + equals: 'SamplePerson' +] + +{ #category : #tests } +MaplessResolversTest >> testMaplessCustomCollectionNameResolver [ + + | customResolver dictionarish | + customResolver := MaplessCustomCollectionNameResolver new. + customResolver translations + at: #Task put: SampleTask name; + yourself. + repository resolver: customResolver. + + dictionarish := Dictionary new + at: '_c' put: 'Item'; + yourself. + + self + should: [ + customResolver maplessClassFor: dictionarish in: repository ] + raise: MaplessClassNotFound. + + dictionarish := Dictionary new + at: '_c' put: 'Task'; + yourself. + self + assert: + (customResolver maplessClassFor: dictionarish in: repository) + equals: SampleTask. + + customResolver translations: (Dictionary new + at: #LaborUnit put: SampleTask name; + yourself). + + repository resolver: customResolver. + + dictionarish := Dictionary new + at: '_c' put: 'Task'; + yourself. + + self + should: [ + customResolver maplessClassFor: dictionarish in: repository ] + raise: MaplessClassNotFound. + + dictionarish := Dictionary new + at: '_c' put: 'LaborUnit'; + yourself. + + self + shouldnt: [ + customResolver maplessClassFor: dictionarish in: repository ] + raise: MaplessClassNotFound. + +] diff --git a/src/Mapless-Mongo-Tests/MaplessStandaloneMongoPoolTest.class.st b/src/Mapless-Mongo-Tests/MaplessStandaloneMongoPoolTest.class.st new file mode 100644 index 00000000..c64feb73 --- /dev/null +++ b/src/Mapless-Mongo-Tests/MaplessStandaloneMongoPoolTest.class.st @@ -0,0 +1,107 @@ +Class { + #name : #MaplessStandaloneMongoPoolTest, + #superclass : #MaplessTestCase, + #category : #'Mapless-Mongo-Tests-Tests' +} + +{ #category : #tests } +MaplessStandaloneMongoPoolTest >> testAuth [ + + | pool | + pool := MaplessStandaloneMongoPool local + username: 'tester'; + password: '123'. + + self + should: [ + pool withClientDo: [ :client | pool authenticate: client ] ] + raise: MaplessMongoAuthorizationError. + + self assert: pool authenticationDatabaseName notNil. + pool authenticationDatabaseName: 'adminis'. + self assert: pool authenticationDatabaseName equals: 'adminis' +] + +{ #category : #tests } +MaplessStandaloneMongoPoolTest >> testHasClients [ + + | pool | + pool := MaplessStandaloneMongoPool local. + + self deny: pool hasClients +] + +{ #category : #tests } +MaplessStandaloneMongoPoolTest >> testMakeMinClients [ + + | pool | + pool := MaplessStandaloneMongoPool local. + + self + deny: pool idleClients size + equals: MaplessStandaloneMongoPool defaultMinClients. + pool start. + + self + assert: pool idleClients size + equals: MaplessStandaloneMongoPool defaultMinClients +] + +{ #category : #tests } +MaplessStandaloneMongoPoolTest >> testMaxClients [ + + | pool | + pool := MaplessStandaloneMongoPool local. + + self + assert: pool maxClients + equals: MaplessStandaloneMongoPool defaultMaxClients +] + +{ #category : #tests } +MaplessStandaloneMongoPoolTest >> testMinClients [ + + | pool | + pool := MaplessStandaloneMongoPool local. + + self + assert: pool minClients + equals: MaplessStandaloneMongoPool defaultMinClients +] + +{ #category : #tests } +MaplessStandaloneMongoPoolTest >> testPurgeUnavailable [ + + | pool | + pool := MaplessStandaloneMongoPool local. + + self deny: pool idleClients size equals: 1. + self assert: pool idleClients size equals: 0. + + pool withClientDo: [ :client | ]. + self assert: pool idleClients size equals: 1. + + pool withClientDo: [ :client | + client close. + self deny: client isValid ]. + + pool purgeUnavailable. + self deny: pool idleClients size equals: 1. + self deny: pool hasClients. + self assert: pool idleClients size equals: 0 +] + +{ #category : #tests } +MaplessStandaloneMongoPoolTest >> testReset [ + + | pool | + pool := MaplessStandaloneMongoPool local. + + self deny: pool idleClients size equals: 1. + + pool withClientDo: [ :client | ]. + + self assert: pool idleClients size equals: 1. + pool reset. + self deny: pool idleClients size equals: 1 +] diff --git a/src/Mapless-Mongo-Tests/MaplessVoyageMongoModelTest.class.st b/src/Mapless-Mongo-Tests/MaplessVoyageMongoModelTest.class.st index ff54ffac..da934efb 100644 --- a/src/Mapless-Mongo-Tests/MaplessVoyageMongoModelTest.class.st +++ b/src/Mapless-Mongo-Tests/MaplessVoyageMongoModelTest.class.st @@ -33,16 +33,36 @@ MaplessVoyageMongoModelTest >> tearDown [ shutDown ] +{ #category : #tests } +MaplessVoyageMongoModelTest >> testConditionForClass [ + + | guy | + repository := MaplessMongoRepository + for: 'Mapless-Test' + with: MaplessStandaloneMongoPool local. + repository resolver: (MaplessVoyageWithMaplessSuffixResolver new + suffix: 'Interoperating'; + yourself). + guy := SamplePersonInteroperating new. + + repository resolver. + self + assert: (repository resolver conditionForClass: guy class) + equals: { ('#instanceOf' -> 'SamplePerson') } asDictionary. + self assert: repository resolver suffix equals: 'Interoperating' +] + { #category : #tests } MaplessVoyageMongoModelTest >> testReifyWithReferenceFromVoyageMetadata [ + | serializedFromVoyage deserializedFromVoyage | - serializedFromVoyage := '{"_id": "596f7169a5aa73b9a2110def", "#instanceOf": "DummyUser","#version":345,"username":"Paul","person":{"__id": "d9b4e739421aa92bd8002411","#collection": "DummyPerson","#instanceOf": "DummyPerson"}}'. + serializedFromVoyage := '{"_id": "596f7169a5aa73b9a2110def", "#instanceOf": "SampleUser","#version":345,"username":"Paul","person":{"__id": "d9b4e739421aa92bd8002411","#collection": "SamplePerson","#instanceOf": "SamplePerson"}}'. deserializedFromVoyage := Mapless - fromJSONString: serializedFromVoyage - in: repository. + fromJSONString: serializedFromVoyage + in: repository. self assert: deserializedFromVoyage class - equals: DummyUserInteroperating. + equals: SampleUserInteroperating. self assert: deserializedFromVoyage username equals: 'Paul'. self assert: deserializedFromVoyage person notNil. self assert: deserializedFromVoyage person class notNil. @@ -53,54 +73,54 @@ MaplessVoyageMongoModelTest >> testReifyWithReferenceFromVoyageMetadata [ { #category : #tests } MaplessVoyageMongoModelTest >> testSaveWithVoyageMetadata [ - | found voyageDummyUserJSON voyageDummyPersonJSON personFromMapless userFromMapless command filter cursor | - voyageDummyUserJSON := '{"_id": "596f7169a5aa73b9a2110def", "#instanceOf": "DummyUser","#version":345,"username":"Paul","person":{"__id": "d9b4e739421aa92bd8002411","#collection": "DummyPerson","#instanceOf": "DummyPerson"}}'. - voyageDummyPersonJSON := '{"_id": "d9b4e739421aa92bd8002411", "#instanceOf": "DummyPerson","#version":345,"firstName":"Buddy"}'. - personFromMapless := DummyPersonInteroperating new - firstName: 'Buddy'; - yourself. - userFromMapless := DummyUserInteroperating new - username: 'buddy'; - person: personFromMapless; - yourself. + + | found voyageSampleUserJSON voyageSamplePersonJSON personFromMapless userFromMapless command filter cursor | + voyageSampleUserJSON := '{"_id": "596f7169a5aa73b9a2110def", "#instanceOf": "SampleUser","#version":345,"username":"Paul","person":{"__id": "d9b4e739421aa92bd8002411","#collection": "SamplePerson","#instanceOf": "SamplePerson"}}'. + voyageSamplePersonJSON := '{"_id": "d9b4e739421aa92bd8002411", "#instanceOf": "SamplePerson","#version":345,"firstName":"Buddy"}'. + personFromMapless := SamplePersonInteroperating new + firstName: 'Buddy'; + yourself. + userFromMapless := SampleUserInteroperating new + username: 'buddy'; + person: personFromMapless; + yourself. repository save: personFromMapless. repository save: userFromMapless. found := repository - findOne: DummyPersonInteroperating - atId: personFromMapless id. + findOne: SamplePersonInteroperating + atId: personFromMapless id. self assert: found notNil. self assert: (found maplessData at: '#instanceOf') - equals: 'DummyPerson'. + equals: 'SamplePerson'. self assert: found id equals: personFromMapless id. found := repository - findOne: DummyUserInteroperating - atId: userFromMapless id. + findOne: SampleUserInteroperating + atId: userFromMapless id. self assert: found notNil. self assert: (found maplessData at: '#instanceOf') - equals: 'DummyUser'. + equals: 'SampleUser'. self assert: found id equals: userFromMapless id. self assert: found person class equals: MaplessReference. self assert: found person model class - equals: DummyPersonInteroperating. + equals: SamplePersonInteroperating. self assert: found person id notNil. self assert: found person id equals: personFromMapless id. self assert: found person model notNil. self assert: found person data notNil. - filter := Dictionary - newFromPairs: - {'_id'. - userFromMapless id}. + filter := Dictionary newFromPairs: { + '_id'. + userFromMapless id }. command := OrderedDictionary new - at: 'find' put: DummyUserInteroperating collectionName; - at: 'filter' put: filter asMongoQuery; - yourself. - repository - readOnlyDo: [ cursor := repository newCursorFor: command. - found := cursor collect: [ :each | each ] ]. + at: 'find' put: SampleUserInteroperating collectionName; + at: 'filter' put: filter asMongoQuery; + yourself. + repository readOnlyDo: [ + cursor := repository newCursorFor: command. + found := cursor collect: [ :each | each ] ]. self assert: found notNil. self assert: found notEmpty. self assert: ((found first at: 'person') includesKey: '__id'). @@ -111,8 +131,8 @@ MaplessVoyageMongoModelTest >> testSaveWithVoyageMetadata [ equals: personFromMapless id. self assert: ((found first at: 'person') at: '#instanceOf') - equals: 'DummyPerson'. + equals: 'SamplePerson'. self assert: ((found first at: 'person') at: '#collection') - equals: 'DummyPerson' + equals: 'SamplePerson' ] diff --git a/src/Mapless-Mongo-Tests/MaplessWithoutDynamicVariableTest.class.st b/src/Mapless-Mongo-Tests/MaplessWithoutDynamicVariableTest.class.st index c4343a83..bc43e719 100644 --- a/src/Mapless-Mongo-Tests/MaplessWithoutDynamicVariableTest.class.st +++ b/src/Mapless-Mongo-Tests/MaplessWithoutDynamicVariableTest.class.st @@ -15,24 +15,24 @@ MaplessWithoutDynamicVariableTest >> testSaveToAndReadFromTwoDatabases [ with: MaplessStandaloneMongoPool local. repositories at: 1 put: repo1. repositories at: 2 put: repo2. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. self deny: guy hasId. repo1 save: guy. self assert: guy hasId. - found := repo1 findOne: DummyPerson atId: guy id. + found := repo1 findOne: SamplePerson atId: guy id. self assert: found notNil. self assert: found firstName equals: guy firstName. - guy := DummyPerson new + guy := SamplePerson new firstName: 'peter'; lastName: 'e'; yourself. self deny: guy hasId. repo2 save: guy. self assert: guy hasId. - found := repo2 findOne: DummyPerson atId: guy id. + found := repo2 findOne: SamplePerson atId: guy id. self assert: found notNil. self assert: found firstName equals: guy firstName ] @@ -44,17 +44,17 @@ MaplessWithoutDynamicVariableTest >> testUseSubmapless [ for: 'Mapless-Test' with: MaplessStandaloneMongoPool local. repositories at: 1 put: repo. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. - user := DummyUser new + user := SampleUser new uername: 'e'; person: guy; yourself. repo save: guy. repo save: user. - found := repo findOne: DummyUser atId: user id. + found := repo findOne: SampleUser atId: user id. self assert: found notNil. self assert: found person firstName equals: guy firstName. self assert: found completeName equals: 'john q' diff --git a/src/Mapless-Mongo-Core/MaplessAbstracMongoPool.class.st b/src/Mapless-Mongo/MaplessAbstracMongoPool.class.st similarity index 90% rename from src/Mapless-Mongo-Core/MaplessAbstracMongoPool.class.st rename to src/Mapless-Mongo/MaplessAbstracMongoPool.class.st index 96b1eb68..1a300fc0 100644 --- a/src/Mapless-Mongo-Core/MaplessAbstracMongoPool.class.st +++ b/src/Mapless-Mongo/MaplessAbstracMongoPool.class.st @@ -1,10 +1,13 @@ +" +I hold commonalities of the Mapless MongoDB clients pool +" Class { #name : #MaplessAbstracMongoPool, #superclass : #MaplessAbstractPool, #instVars : [ 'authenticationDatabaseName' ], - #category : #'Mapless-Mongo-Core-Connections' + #category : #'Mapless-Mongo-Connections' } { #category : #'instance creation' } diff --git a/src/Mapless-Mongo/MaplessMongoAuthorizationError.class.st b/src/Mapless-Mongo/MaplessMongoAuthorizationError.class.st new file mode 100644 index 00000000..e36f9b51 --- /dev/null +++ b/src/Mapless-Mongo/MaplessMongoAuthorizationError.class.st @@ -0,0 +1,8 @@ +" +I signal when MongoDB didn't like the username and password +" +Class { + #name : #MaplessMongoAuthorizationError, + #superclass : #MaplessMongoError, + #category : #'Mapless-Mongo-Errors' +} diff --git a/src/Mapless-Mongo-Core/MaplessMongoError.class.st b/src/Mapless-Mongo/MaplessMongoError.class.st similarity index 88% rename from src/Mapless-Mongo-Core/MaplessMongoError.class.st rename to src/Mapless-Mongo/MaplessMongoError.class.st index ae0de5a7..81adcbd8 100644 --- a/src/Mapless-Mongo-Core/MaplessMongoError.class.st +++ b/src/Mapless-Mongo/MaplessMongoError.class.st @@ -1,10 +1,13 @@ +" +I'm a Mapless error that can signal when something specific to MongoDB went bad +" Class { #name : #MaplessMongoError, #superclass : #MaplessError, #instVars : [ 'mongoCommandError' ], - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } { #category : #'instance creation' } diff --git a/src/Mapless-Mongo-Core/MaplessMongoPrimaryUnavailable.class.st b/src/Mapless-Mongo/MaplessMongoPrimaryUnavailable.class.st similarity index 85% rename from src/Mapless-Mongo-Core/MaplessMongoPrimaryUnavailable.class.st rename to src/Mapless-Mongo/MaplessMongoPrimaryUnavailable.class.st index 3fc7a78e..2a4223fa 100644 --- a/src/Mapless-Mongo-Core/MaplessMongoPrimaryUnavailable.class.st +++ b/src/Mapless-Mongo/MaplessMongoPrimaryUnavailable.class.st @@ -5,5 +5,5 @@ It might be because this happened during the election process or is not setup Class { #name : #MaplessMongoPrimaryUnavailable, #superclass : #MaplessMongoReplicaSetError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessMongoReplicaSetError.class.st b/src/Mapless-Mongo/MaplessMongoReplicaSetError.class.st similarity index 66% rename from src/Mapless-Mongo-Core/MaplessMongoReplicaSetError.class.st rename to src/Mapless-Mongo/MaplessMongoReplicaSetError.class.st index 418cf977..ed8717a8 100644 --- a/src/Mapless-Mongo-Core/MaplessMongoReplicaSetError.class.st +++ b/src/Mapless-Mongo/MaplessMongoReplicaSetError.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessMongoReplicaSetError, #superclass : #MaplessMongoError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessMongoReplicaSetPool.class.st b/src/Mapless-Mongo/MaplessMongoReplicaSetPool.class.st similarity index 98% rename from src/Mapless-Mongo-Core/MaplessMongoReplicaSetPool.class.st rename to src/Mapless-Mongo/MaplessMongoReplicaSetPool.class.st index 0036ced2..6a75344c 100644 --- a/src/Mapless-Mongo-Core/MaplessMongoReplicaSetPool.class.st +++ b/src/Mapless-Mongo/MaplessMongoReplicaSetPool.class.st @@ -22,7 +22,7 @@ Class { 'healthChecker', 'healthCheckerInterval' ], - #category : #'Mapless-Mongo-Core-Connections' + #category : #'Mapless-Mongo-Connections' } { #category : #default } @@ -422,13 +422,27 @@ MaplessMongoReplicaSetPool >> initializeIdleReadWriteClients [ ^ idleReadWriteClients := IdentitySet new ] +{ #category : #initialization } +MaplessMongoReplicaSetPool >> initializeMaxReadOnlyClients [ + + ^ maxReadOnlyClients := self class defaultMaxReadOnlyClients +] + +{ #category : #initialization } +MaplessMongoReplicaSetPool >> initializeMaxReadWriteClients [ + + ^ maxReadWriteClients := self class defaultMaxReadWriteClients +] + { #category : #initialization } MaplessMongoReplicaSetPool >> initializeMinReadOnlyClients [ + ^ minReadOnlyClients := self class defaultMinReadOnlyClients ] { #category : #initialization } MaplessMongoReplicaSetPool >> initializeMinReadWriteClients [ + ^ minReadWriteClients := self class defaultMinReadWriteClients ] @@ -528,7 +542,8 @@ MaplessMongoReplicaSetPool >> makeReadWriteClient [ { #category : #accessing } MaplessMongoReplicaSetPool >> maxReadOnlyClients [ - ^ maxReadOnlyClients + + ^ maxReadOnlyClients ifNil: [ self initializeMaxReadOnlyClients ] ] { #category : #accessing } @@ -538,7 +553,8 @@ MaplessMongoReplicaSetPool >> maxReadOnlyClients: anObject [ { #category : #accessing } MaplessMongoReplicaSetPool >> maxReadWriteClients [ - ^ maxReadWriteClients + + ^ maxReadWriteClients ifNil: [ self initializeMaxReadWriteClients ] ] { #category : #accessing } diff --git a/src/Mapless-Mongo-Core/MaplessMongoReplicaSetResolver.class.st b/src/Mapless-Mongo/MaplessMongoReplicaSetResolver.class.st similarity index 98% rename from src/Mapless-Mongo-Core/MaplessMongoReplicaSetResolver.class.st rename to src/Mapless-Mongo/MaplessMongoReplicaSetResolver.class.st index fcbbd150..fa24f425 100644 --- a/src/Mapless-Mongo-Core/MaplessMongoReplicaSetResolver.class.st +++ b/src/Mapless-Mongo/MaplessMongoReplicaSetResolver.class.st @@ -10,7 +10,7 @@ Class { 'primaryUrl', 'secondaryUrls' ], - #category : #'Mapless-Mongo-Core-Connections' + #category : #'Mapless-Mongo-Connections' } { #category : #'instance creation' } diff --git a/src/Mapless-Mongo-Core/MaplessMongoRepository.class.st b/src/Mapless-Mongo/MaplessMongoRepository.class.st similarity index 99% rename from src/Mapless-Mongo-Core/MaplessMongoRepository.class.st rename to src/Mapless-Mongo/MaplessMongoRepository.class.st index 3f826338..f03d4051 100644 --- a/src/Mapless-Mongo-Core/MaplessMongoRepository.class.st +++ b/src/Mapless-Mongo/MaplessMongoRepository.class.st @@ -12,7 +12,7 @@ Class { 'concerns', 'defaultConcerns' ], - #category : #'Mapless-Mongo-Core-Connections' + #category : #'Mapless-Mongo-Connections' } { #category : #actions } @@ -234,11 +234,6 @@ MaplessMongoRepository >> drop [ ^ self readWriteDo: [ self database drop ] ] -{ #category : #actions } -MaplessMongoRepository >> ensureCollection [ - self shouldBeImplemented -] - { #category : #testing } MaplessMongoRepository >> existsId: anId of: aMaplessClass [ ^ (self @@ -717,6 +712,11 @@ MaplessMongoRepository >> withClientDo: aBlock with: aDatabaseAccessor [ ^ self withReadWriteClientDo: aBlock with: aDatabaseAccessor ] +{ #category : #actions } +MaplessMongoRepository >> withReadOnlyClientDo: aBlock [ + ^ self withReadOnlyClientDo: aBlock with: accessor +] + { #category : #actions } MaplessMongoRepository >> withReadOnlyClientDo: aBlock with: aDatabaseAccessor [ aDatabaseAccessor @@ -739,8 +739,3 @@ MaplessMongoRepository >> withReadWriteClientDo: aBlock with: aDatabaseAccessor value: self during: [ ^ aBlock value: client ] ] ] - -{ #category : #actions } -MaplessMongoRepository >> withReadnlyClientDo: aBlock [ - ^ self withReadOnlyClientDo: aBlock with: accessor -] diff --git a/src/Mapless-Mongo-Core/MaplessMongoUnavailableDatabase.class.st b/src/Mapless-Mongo/MaplessMongoUnavailableDatabase.class.st similarity index 67% rename from src/Mapless-Mongo-Core/MaplessMongoUnavailableDatabase.class.st rename to src/Mapless-Mongo/MaplessMongoUnavailableDatabase.class.st index 4de6e9c0..a7cc9741 100644 --- a/src/Mapless-Mongo-Core/MaplessMongoUnavailableDatabase.class.st +++ b/src/Mapless-Mongo/MaplessMongoUnavailableDatabase.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessMongoUnavailableDatabase, #superclass : #MaplessMongoError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessNoReplicaSetMemberCouldBeReached.class.st b/src/Mapless-Mongo/MaplessNoReplicaSetMemberCouldBeReached.class.st similarity index 71% rename from src/Mapless-Mongo-Core/MaplessNoReplicaSetMemberCouldBeReached.class.st rename to src/Mapless-Mongo/MaplessNoReplicaSetMemberCouldBeReached.class.st index 297e2681..375ab158 100644 --- a/src/Mapless-Mongo-Core/MaplessNoReplicaSetMemberCouldBeReached.class.st +++ b/src/Mapless-Mongo/MaplessNoReplicaSetMemberCouldBeReached.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessNoReplicaSetMemberCouldBeReached, #superclass : #MaplessMongoReplicaSetError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessPrimaryClientsAllBusy.class.st b/src/Mapless-Mongo/MaplessPrimaryClientsAllBusy.class.st similarity index 69% rename from src/Mapless-Mongo-Core/MaplessPrimaryClientsAllBusy.class.st rename to src/Mapless-Mongo/MaplessPrimaryClientsAllBusy.class.st index 9ca438f8..d4739b04 100644 --- a/src/Mapless-Mongo-Core/MaplessPrimaryClientsAllBusy.class.st +++ b/src/Mapless-Mongo/MaplessPrimaryClientsAllBusy.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessPrimaryClientsAllBusy, #superclass : #MaplessMongoReplicaSetError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessReadOnlyOperationFailed.class.st b/src/Mapless-Mongo/MaplessReadOnlyOperationFailed.class.st similarity index 67% rename from src/Mapless-Mongo-Core/MaplessReadOnlyOperationFailed.class.st rename to src/Mapless-Mongo/MaplessReadOnlyOperationFailed.class.st index bdaa3a46..690119e6 100644 --- a/src/Mapless-Mongo-Core/MaplessReadOnlyOperationFailed.class.st +++ b/src/Mapless-Mongo/MaplessReadOnlyOperationFailed.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessReadOnlyOperationFailed, #superclass : #MaplessMongoError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessReadWriteOperationFailed.class.st b/src/Mapless-Mongo/MaplessReadWriteOperationFailed.class.st similarity index 67% rename from src/Mapless-Mongo-Core/MaplessReadWriteOperationFailed.class.st rename to src/Mapless-Mongo/MaplessReadWriteOperationFailed.class.st index 84c7d1a4..5e833d97 100644 --- a/src/Mapless-Mongo-Core/MaplessReadWriteOperationFailed.class.st +++ b/src/Mapless-Mongo/MaplessReadWriteOperationFailed.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessReadWriteOperationFailed, #superclass : #MaplessMongoError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessReplicaSetInconsistentConfiguration.class.st b/src/Mapless-Mongo/MaplessReplicaSetInconsistentConfiguration.class.st similarity index 72% rename from src/Mapless-Mongo-Core/MaplessReplicaSetInconsistentConfiguration.class.st rename to src/Mapless-Mongo/MaplessReplicaSetInconsistentConfiguration.class.st index 4f5fd4f5..d2810321 100644 --- a/src/Mapless-Mongo-Core/MaplessReplicaSetInconsistentConfiguration.class.st +++ b/src/Mapless-Mongo/MaplessReplicaSetInconsistentConfiguration.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessReplicaSetInconsistentConfiguration, #superclass : #MaplessMongoReplicaSetError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessReplicaSetNodeRoleChanged.class.st b/src/Mapless-Mongo/MaplessReplicaSetNodeRoleChanged.class.st similarity index 70% rename from src/Mapless-Mongo-Core/MaplessReplicaSetNodeRoleChanged.class.st rename to src/Mapless-Mongo/MaplessReplicaSetNodeRoleChanged.class.st index 2e7294b4..d34b4027 100644 --- a/src/Mapless-Mongo-Core/MaplessReplicaSetNodeRoleChanged.class.st +++ b/src/Mapless-Mongo/MaplessReplicaSetNodeRoleChanged.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessReplicaSetNodeRoleChanged, #superclass : #MaplessMongoReplicaSetError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessSecondaryClientsAllBusy.class.st b/src/Mapless-Mongo/MaplessSecondaryClientsAllBusy.class.st similarity index 69% rename from src/Mapless-Mongo-Core/MaplessSecondaryClientsAllBusy.class.st rename to src/Mapless-Mongo/MaplessSecondaryClientsAllBusy.class.st index e96ae05a..f252c16a 100644 --- a/src/Mapless-Mongo-Core/MaplessSecondaryClientsAllBusy.class.st +++ b/src/Mapless-Mongo/MaplessSecondaryClientsAllBusy.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessSecondaryClientsAllBusy, #superclass : #MaplessMongoReplicaSetError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/MaplessStandaloneMongoPool.class.st b/src/Mapless-Mongo/MaplessStandaloneMongoPool.class.st similarity index 92% rename from src/Mapless-Mongo-Core/MaplessStandaloneMongoPool.class.st rename to src/Mapless-Mongo/MaplessStandaloneMongoPool.class.st index a0450721..f8f2de12 100644 --- a/src/Mapless-Mongo-Core/MaplessStandaloneMongoPool.class.st +++ b/src/Mapless-Mongo/MaplessStandaloneMongoPool.class.st @@ -10,11 +10,11 @@ Class { 'minClients', 'maxClients', 'clientsMutex', - 'clientsMonitor', 'busyClients', - 'idleClients' + 'idleClients', + 'clientsMonitor' ], - #category : #'Mapless-Mongo-Core-Connections' + #category : #'Mapless-Mongo-Connections' } { #category : #'instance creation' } @@ -58,13 +58,6 @@ MaplessStandaloneMongoPool >> clientsMonitor [ ^ clientsMonitor ifNil: [ self initializeClientsMonitor ] ] -{ #category : #accessing } -MaplessStandaloneMongoPool >> clientsMutex [ - "Answers the mutex used to protect clients usage" - - ^ clientsMutex ifNil: [ self initializeClientsMutex ] -] - { #category : #accessing } MaplessStandaloneMongoPool >> currentClientDynamicVariableClass [ "Answers the class of the dynamic variable that will @@ -138,12 +131,8 @@ MaplessStandaloneMongoPool >> initializeBusyClients [ { #category : #initialization } MaplessStandaloneMongoPool >> initializeClientsMonitor [ - ^ clientsMonitor := Monitor new -] -{ #category : #initialization } -MaplessStandaloneMongoPool >> initializeClientsMutex [ - ^ clientsMutex := Mutex new + ^ clientsMonitor := Monitor new ] { #category : #initialization } @@ -167,12 +156,12 @@ MaplessStandaloneMongoPool >> makeClient [ | newMongoClient isAuthenticated | newMongoClient := (MongoAPI host: hostname port: port asInteger) - open; - yourself. - self isUsingAuth - ifTrue: [ isAuthenticated := self authenticate: newMongoClient. - isAuthenticated - ifFalse: [ ^ self error: 'Authentication failed' ] ]. + open; + yourself. + self isUsingAuth ifTrue: [ + isAuthenticated := self authenticate: newMongoClient. + isAuthenticated ifFalse: [ + ^ MaplessMongoAuthorizationError signal: 'Authentication failed' ] ]. ^ newMongoClient ] @@ -196,11 +185,6 @@ MaplessStandaloneMongoPool >> minClients: anObject [ minClients := anObject ] -{ #category : #reactions } -MaplessStandaloneMongoPool >> onLogout: aMongoClient [ - self remove: aMongoClient -] - { #category : #actions } MaplessStandaloneMongoPool >> printOn: aStream [ super printOn: aStream. diff --git a/src/Mapless-Mongo-Core/Mongo.extension.st b/src/Mapless-Mongo/Mongo.extension.st similarity index 83% rename from src/Mapless-Mongo-Core/Mongo.extension.st rename to src/Mapless-Mongo/Mongo.extension.st index 7bd85131..ff9ec771 100644 --- a/src/Mapless-Mongo-Core/Mongo.extension.st +++ b/src/Mapless-Mongo/Mongo.extension.st @@ -1,6 +1,6 @@ Extension { #name : #Mongo } -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } Mongo >> authenticateUsername: user password: pass database: aDatabaseName [ ^ self authMechanism authenticateUsername: user @@ -8,7 +8,7 @@ Mongo >> authenticateUsername: user password: pass database: aDatabaseName [ database: (MongoDatabase root: self name: aDatabaseName) ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } Mongo >> printOn: aStream [ aStream nextPutAll: self class name , ' ('; diff --git a/src/Mapless-Mongo-Core/MongoAPI.class.st b/src/Mapless-Mongo/MongoAPI.class.st similarity index 95% rename from src/Mapless-Mongo-Core/MongoAPI.class.st rename to src/Mapless-Mongo/MongoAPI.class.st index 67e30ccb..ac692540 100644 --- a/src/Mapless-Mongo-Core/MongoAPI.class.st +++ b/src/Mapless-Mongo/MongoAPI.class.st @@ -1,3 +1,6 @@ +" +I'm a specialized API to help Mapless use MongoTalk +" Class { #name : #MongoAPI, #superclass : #Mongo, @@ -5,7 +8,7 @@ Class { 'isPrimary', 'mongoUrl' ], - #category : #'Mapless-Mongo-Core-Connections' + #category : #'Mapless-Mongo-Connections' } { #category : #'as yet unclassified' } diff --git a/src/Mapless-Mongo-Core/MongoCommandError.extension.st b/src/Mapless-Mongo/MongoCommandError.extension.st similarity index 80% rename from src/Mapless-Mongo-Core/MongoCommandError.extension.st rename to src/Mapless-Mongo/MongoCommandError.extension.st index 6803baf3..3758c726 100644 --- a/src/Mapless-Mongo-Core/MongoCommandError.extension.st +++ b/src/Mapless-Mongo/MongoCommandError.extension.st @@ -1,11 +1,11 @@ Extension { #name : #MongoCommandError } -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoCommandError class >> code [ ^ nil ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoCommandError class >> signalFor: aReply [ | errorClass | errorClass := self allSubclasses diff --git a/src/Mapless-Mongo/MongoCurrentClient.class.st b/src/Mapless-Mongo/MongoCurrentClient.class.st new file mode 100644 index 00000000..d303ace9 --- /dev/null +++ b/src/Mapless-Mongo/MongoCurrentClient.class.st @@ -0,0 +1,8 @@ +" +I hold the MongoAPI instance used in the current process (if so) +" +Class { + #name : #MongoCurrentClient, + #superclass : #DynamicVariable, + #category : #'Mapless-Mongo-Connections' +} diff --git a/src/Mapless-Mongo-Core/MongoCursor.extension.st b/src/Mapless-Mongo/MongoCursor.extension.st similarity index 95% rename from src/Mapless-Mongo-Core/MongoCursor.extension.st rename to src/Mapless-Mongo/MongoCursor.extension.st index 9d931478..e83b34dc 100644 --- a/src/Mapless-Mongo-Core/MongoCursor.extension.st +++ b/src/Mapless-Mongo/MongoCursor.extension.st @@ -1,6 +1,6 @@ Extension { #name : #MongoCursor } -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoCursor >> execute [ | limit reply numberReturned requestId | numberReturned := 0. diff --git a/src/Mapless-Mongo-Core/MongoDatabase.extension.st b/src/Mapless-Mongo/MongoDatabase.extension.st similarity index 91% rename from src/Mapless-Mongo-Core/MongoDatabase.extension.st rename to src/Mapless-Mongo/MongoDatabase.extension.st index 01b6c63b..5adbde99 100644 --- a/src/Mapless-Mongo-Core/MongoDatabase.extension.st +++ b/src/Mapless-Mongo/MongoDatabase.extension.st @@ -1,6 +1,6 @@ Extension { #name : #MongoDatabase } -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoDatabase >> commandUpdate: origDictionary with: newDictionary collection: collectionName writeConcern: aConcern [ ^ self commandUpdate: origDictionary @@ -11,7 +11,7 @@ MongoDatabase >> commandUpdate: origDictionary with: newDictionary collection: c multi: false ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoDatabase >> commandUpdate: origDictionary with: newDictionary collection: collectionName writeConcern: aConcern upsert: isUpsert multi: isMulti [ "Update using Mongo command. Answer the output of the command. See more on https://docs.mongodb.com/manual/reference/command/update/" @@ -30,7 +30,7 @@ MongoDatabase >> commandUpdate: origDictionary with: newDictionary collection: c ^ self commandAndVerify: dict ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoDatabase >> commandUpsert: origDictionary with: newDictionary collection: collectionName writeConcern: aConcern [ ^ self commandUpdate: origDictionary diff --git a/src/Mapless-Mongo-Core/MongoNotMaster.class.st b/src/Mapless-Mongo/MongoNotMaster.class.st similarity index 77% rename from src/Mapless-Mongo-Core/MongoNotMaster.class.st rename to src/Mapless-Mongo/MongoNotMaster.class.st index b5848316..22d952f3 100644 --- a/src/Mapless-Mongo-Core/MongoNotMaster.class.st +++ b/src/Mapless-Mongo/MongoNotMaster.class.st @@ -1,7 +1,7 @@ Class { #name : #MongoNotMaster, #superclass : #MongoCommandError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } { #category : #accessing } diff --git a/src/Mapless-Mongo-Core/MongoOperationError.class.st b/src/Mapless-Mongo/MongoOperationError.class.st similarity index 92% rename from src/Mapless-Mongo-Core/MongoOperationError.class.st rename to src/Mapless-Mongo/MongoOperationError.class.st index a8f16071..49b121fb 100644 --- a/src/Mapless-Mongo-Core/MongoOperationError.class.st +++ b/src/Mapless-Mongo/MongoOperationError.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'reply' ], - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } { #category : #'instance creation' } diff --git a/src/Mapless-Mongo-Core/MongoReplicaSetStatus.extension.st b/src/Mapless-Mongo/MongoReplicaSetStatus.extension.st similarity index 76% rename from src/Mapless-Mongo-Core/MongoReplicaSetStatus.extension.st rename to src/Mapless-Mongo/MongoReplicaSetStatus.extension.st index b98047db..6c8cd5c3 100644 --- a/src/Mapless-Mongo-Core/MongoReplicaSetStatus.extension.st +++ b/src/Mapless-Mongo/MongoReplicaSetStatus.extension.st @@ -1,6 +1,6 @@ Extension { #name : #MongoReplicaSetStatus } -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatus >> secondaryMembers [ ^ self members select: #isSecondary ] diff --git a/src/Mapless-Mongo-Core/MongoReplicaSetStatusMember.extension.st b/src/Mapless-Mongo/MongoReplicaSetStatusMember.extension.st similarity index 86% rename from src/Mapless-Mongo-Core/MongoReplicaSetStatusMember.extension.st rename to src/Mapless-Mongo/MongoReplicaSetStatusMember.extension.st index b98c04ce..d10c9ccf 100644 --- a/src/Mapless-Mongo-Core/MongoReplicaSetStatusMember.extension.st +++ b/src/Mapless-Mongo/MongoReplicaSetStatusMember.extension.st @@ -1,6 +1,6 @@ Extension { #name : #MongoReplicaSetStatusMember } -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatusMember >> isArbiter [ "Arbiters do not replicate data and exist solely to participate in elections. Eligible to vote. @@ -8,12 +8,12 @@ MongoReplicaSetStatusMember >> isArbiter [ ^self state = 7 ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatusMember >> isDown [ ^self state = 8 ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatusMember >> isRecovering [ "Members either perform startup self-checks, or transition from completing a rollback or resync. @@ -23,14 +23,14 @@ MongoReplicaSetStatusMember >> isRecovering [ ^self state = 3 ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatusMember >> isRemoved [ "This member was once in a replica set but was subsequently removed. https://www.mongodb.com/docs/manual/reference/replica-states" ^self state = 10 ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatusMember >> isRollback [ "This member is actively performing a rollback. Eligible to vote. Data is not available for reads from this member. @@ -40,7 +40,7 @@ MongoReplicaSetStatusMember >> isRollback [ ^self state = 9 ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatusMember >> isStartup [ "Not yet an active member of any set. All members start up in this state. @@ -50,7 +50,7 @@ MongoReplicaSetStatusMember >> isStartup [ ^self state = 0 ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatusMember >> isStartup2 [ "The member has joined the set and is running an initial sync. Eligible to vote. @@ -61,7 +61,7 @@ MongoReplicaSetStatusMember >> isStartup2 [ ^self state = 5 ] -{ #category : #'*Mapless-Mongo-Core' } +{ #category : #'*Mapless-Mongo' } MongoReplicaSetStatusMember >> isUnkown [ "The member's state, as seen from another member of the set, is not yet known. https://www.mongodb.com/docs/manual/reference/replica-states" diff --git a/src/Mapless-Mongo-Core/ReplicaSetPrimaryNotFound.class.st b/src/Mapless-Mongo/ReplicaSetPrimaryNotFound.class.st similarity index 66% rename from src/Mapless-Mongo-Core/ReplicaSetPrimaryNotFound.class.st rename to src/Mapless-Mongo/ReplicaSetPrimaryNotFound.class.st index a320aa88..c1d76014 100644 --- a/src/Mapless-Mongo-Core/ReplicaSetPrimaryNotFound.class.st +++ b/src/Mapless-Mongo/ReplicaSetPrimaryNotFound.class.st @@ -1,5 +1,5 @@ Class { #name : #ReplicaSetPrimaryNotFound, #superclass : #MaplessMongoError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo-Core/ReplicaSetSecondaryNotFound.class.st b/src/Mapless-Mongo/ReplicaSetSecondaryNotFound.class.st similarity index 66% rename from src/Mapless-Mongo-Core/ReplicaSetSecondaryNotFound.class.st rename to src/Mapless-Mongo/ReplicaSetSecondaryNotFound.class.st index 62323ca5..5a7fd642 100644 --- a/src/Mapless-Mongo-Core/ReplicaSetSecondaryNotFound.class.st +++ b/src/Mapless-Mongo/ReplicaSetSecondaryNotFound.class.st @@ -1,5 +1,5 @@ Class { #name : #ReplicaSetSecondaryNotFound, #superclass : #MaplessMongoError, - #category : #'Mapless-Mongo-Core-Errors' + #category : #'Mapless-Mongo-Errors' } diff --git a/src/Mapless-Mongo/package.st b/src/Mapless-Mongo/package.st new file mode 100644 index 00000000..8a309d0a --- /dev/null +++ b/src/Mapless-Mongo/package.st @@ -0,0 +1 @@ +Package { #name : #'Mapless-Mongo' } diff --git a/src/Mapless-Postgres-Core/package.st b/src/Mapless-Postgres-Core/package.st deleted file mode 100644 index 8b5ad406..00000000 --- a/src/Mapless-Postgres-Core/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Mapless-Postgres-Core' } diff --git a/src/Mapless-Postgres-Tests/MaplessPostgresTest.class.st b/src/Mapless-Postgres-Tests/MaplessPostgresTest.class.st index fb0ea46b..5e0f4409 100644 --- a/src/Mapless-Postgres-Tests/MaplessPostgresTest.class.st +++ b/src/Mapless-Postgres-Tests/MaplessPostgresTest.class.st @@ -30,9 +30,9 @@ MaplessPostgresTest class >> lastStoredRun [ { #category : #history } MaplessPostgresTest class >> maplessClasses [ - ^ {DummyPerson. - DummyUser. - DummyTag} + ^ {SamplePerson. + SampleUser. + SampleTag} ] { #category : #actions } @@ -50,7 +50,7 @@ MaplessPostgresTest >> resetDatabase [ MaplessPostgresTest >> savePersonNamed: aString [ repository save: - (DummyPerson new + (SamplePerson new firstName: aString; yourself) ] @@ -77,10 +77,10 @@ MaplessPostgresTest >> testComposedAccess [ "Test proxies and its on-demand-load and DNU mechanism" | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -88,19 +88,19 @@ MaplessPostgresTest >> testComposedAccess [ repository save: guy. repository save: user. self - assert: (repository findOne: DummyUser atId: user id) completeName + assert: (repository findOne: SampleUser atId: user id) completeName equals: 'john q'. self - assert: (repository findOne: DummyUser atId: user id) person class + assert: (repository findOne: SampleUser atId: user id) person class equals: MaplessReference. self - assert: (repository findOne: DummyUser atId: user id) person model class - equals: DummyPerson. + assert: (repository findOne: SampleUser atId: user id) person model class + equals: SamplePerson. self - assert: (repository findOne: DummyUser atId: user id) person firstName + assert: (repository findOne: SampleUser atId: user id) person firstName equals: 'john'. self - assert: (repository findOne: DummyUser atId: user id) person lastName + assert: (repository findOne: SampleUser atId: user id) person lastName equals: 'q' ] @@ -112,10 +112,10 @@ MaplessPostgresTest >> testComposedDelete [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -140,10 +140,10 @@ MaplessPostgresTest >> testComposedDestroy [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -153,31 +153,31 @@ MaplessPostgresTest >> testComposedDestroy [ assert: (users allSatisfy: - [ :user | (repository findOne: DummyPerson atId: user person id) notNil ]). + [ :user | (repository findOne: SamplePerson atId: user person id) notNil ]). users do: [ :user | repository destroy: user person ]. self assert: (users allSatisfy: - [ :user | (repository findOne: DummyPerson atId: user person id) isNil ]). + [ :user | (repository findOne: SamplePerson atId: user person id) isNil ]). self assert: (users - allSatisfy: [ :user | (repository findOne: DummyUser atId: user id) notNil ]). + allSatisfy: [ :user | (repository findOne: SampleUser atId: user id) notNil ]). users do: [ :user | repository destroy: user ]. self assert: (users - allSatisfy: [ :user | (repository findOne: DummyUser atId: user id) isNil ]) + allSatisfy: [ :user | (repository findOne: SampleUser atId: user id) isNil ]) ] { #category : #tests } MaplessPostgresTest >> testComposedSave [ | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -197,11 +197,11 @@ MaplessPostgresTest >> testComposedSave [ MaplessPostgresTest >> testComposedSaveAndLoad [ | user guy loaded when | when := DateAndTime now asUTC. - user := DummyUser new + user := SampleUser new createdOn: when; username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new createdOn: when; firstName: 'john'; lastName: 'q'; @@ -216,7 +216,7 @@ MaplessPostgresTest >> testComposedSaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded notNil. self assert: loaded createdOn notNil. self assert: loaded modifiedOn notNil. @@ -233,24 +233,24 @@ MaplessPostgresTest >> testComposedSaveAndLoad [ self assert: loaded username = 'johnq'. self assert: loaded person firstName = 'john'. self assert: loaded person lastName = 'q'. - self assert: loaded person maplessClassName = #DummyPerson. - self assert: loaded person model class = DummyPerson + self assert: loaded person maplessClassName = #SamplePerson. + self assert: loaded person model class = SamplePerson ] { #category : #tests } MaplessPostgresTest >> testComposition [ | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. self assert: (user maplessData at: 'person') class - equals: DummyPerson. + equals: SamplePerson. self assert: user id isNil. self assert: (user maplessData at: 'person') id isNil. self assert: user completeName equals: 'john q' @@ -264,10 +264,10 @@ MaplessPostgresTest >> testConditionalCount [ do: [ :char | users add: - (DummyUser new + (SampleUser new username: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -281,7 +281,7 @@ MaplessPostgresTest >> testConditionalCount [ 'firstName'. firstNames asJSONString allButFirst allButLast replaceAll: $" with: $'}. self - assert: (repository count: DummyPerson where: sqlCondition) + assert: (repository count: SamplePerson where: sqlCondition) equals: firstNames size ] @@ -293,17 +293,17 @@ MaplessPostgresTest >> testCount [ do: [ :char | users add: - (DummyUser new + (SampleUser new username: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. users do: [ :user | repository save: user person ]. users do: [ :user | repository save: user ]. self - assert: (repository count: DummyUser) + assert: (repository count: SampleUser) equals: Character alphabet size ] @@ -315,7 +315,7 @@ MaplessPostgresTest >> testDelete [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -332,7 +332,7 @@ MaplessPostgresTest >> testDestroy [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -341,24 +341,24 @@ MaplessPostgresTest >> testDestroy [ self assert: (people - allSatisfy: [ :guy | (repository findOne: DummyPerson atId: guy id) isNil ]) + allSatisfy: [ :guy | (repository findOne: SamplePerson atId: guy id) isNil ]) ] { #category : #tests } MaplessPostgresTest >> testExists [ | guy loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - self assert: (repository existsId: guy id of: DummyPerson) + self assert: (repository existsId: guy id of: SamplePerson) ] { #category : #tests } MaplessPostgresTest >> testIsUnsaved [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -377,35 +377,35 @@ MaplessPostgresTest >> testMultipleComposedComposables [ tagsOfTagsOfTags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'is this'; yourself); add: - (DummyTag new + (SampleTag new label: 'multiply'; yourself); add: - (DummyTag new + (SampleTag new label: 'composable?'; yourself); yourself. tagsOfTags add: - (DummyTag new + (SampleTag new label: 'like'; yourself); add: - (DummyTag new + (SampleTag new label: 'really?'; yourself); yourself. tagsOfTagsOfTags add: - (DummyTag new + (SampleTag new label: 'wow'; yourself); add: - (DummyTag new + (SampleTag new label: 'nice'; yourself); yourself. @@ -421,7 +421,7 @@ MaplessPostgresTest >> testMultipleComposedComposables [ self shouldnt: [ tags do: [ :e | repository save: e ] ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyTag atId: tags first id. + loaded := repository findOne: SampleTag atId: tags first id. self assert: loaded notNil. self assert: loaded label = 'is this'. self assert: loaded tags isCollection. @@ -440,29 +440,29 @@ MaplessPostgresTest >> testMultipleComposedComposables [ { #category : #tests } MaplessPostgresTest >> testMultipleComposedMixedSaveAndLoad [ | guy things loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. guy things: OrderedCollection new. guy things add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); add: - (DummyUser new + (SampleUser new info: 'also this'; yourself); yourself. things := guy things. guy things do: [ :each | repository save: each ]. self shouldnt: [ repository save: guy ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded notNil. self assert: loaded firstName = 'john'. self assert: loaded things isCollection. @@ -470,29 +470,29 @@ MaplessPostgresTest >> testMultipleComposedMixedSaveAndLoad [ loaded things do: [ :each | self assert: (things anySatisfy: [ :t | t id = each id ]) ]. loaded unreferenced. - self assert: loaded things first class = DummyTag. - self assert: loaded things second class = DummyTag. - self assert: loaded things third class = DummyUser + self assert: loaded things first class = SampleTag. + self assert: loaded things second class = SampleTag. + self assert: loaded things third class = SampleUser ] { #category : #tests } MaplessPostgresTest >> testMultipleComposedSaveAndLoad [ | user guy tags loaded | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. tags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); yourself. @@ -505,7 +505,7 @@ MaplessPostgresTest >> testMultipleComposedSaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded notNil. self assert: loaded username = 'johnq'. self assert: loaded tags isCollection. @@ -523,10 +523,10 @@ MaplessPostgresTest >> testQueryUsers [ do: [ :char | users add: - (DummyUser new + (SampleUser new username: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -537,7 +537,7 @@ MaplessPostgresTest >> testQueryUsers [ (Character alphabet allSatisfy: [ :char | (repository - findOne: DummyUser + findOne: SampleUser where: ('maplessData->>''{1}'' = ''{2}''' format: @@ -548,7 +548,7 @@ MaplessPostgresTest >> testQueryUsers [ { #category : #tests } MaplessPostgresTest >> testSaveSetsID [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -561,7 +561,7 @@ MaplessPostgresTest >> testSaveSetsID [ { #category : #tests } MaplessPostgresTest >> testSimpleSave [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -571,12 +571,12 @@ MaplessPostgresTest >> testSimpleSave [ { #category : #tests } MaplessPostgresTest >> testSimpleSaveAndLoad [ | guy loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded notNil. loaded modifiedOn: nil. guy modifiedOn: nil. @@ -589,37 +589,37 @@ MaplessPostgresTest >> testSimpleSaveAndLoad [ { #category : #tests } MaplessPostgresTest >> testSimpleSaveAndUpdate [ | guy loaded reloaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded firstName = 'john'. self deny: loaded remember = 'this words'. loaded firstName: loaded firstName capitalized. loaded remember: 'this words'. repository save: loaded. - reloaded := repository findOne: DummyPerson atId: guy id. + reloaded := repository findOne: SamplePerson atId: guy id. self assert: reloaded remember = 'this words' ] { #category : #tests } MaplessPostgresTest >> testSubModelsFromReifiedJSON [ | user guy jsonString reified loaded | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. repository save: guy. repository save: user. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. jsonString := loaded unreferenced asJSONString. - reified := DummyUser fromJSONString: jsonString in: repository. - self assert: reified person class equals: DummyPerson. + reified := SampleUser fromJSONString: jsonString in: repository. + self assert: reified person class equals: SamplePerson. self assert: reified completeName equals: 'john q' ] diff --git a/src/Mapless-Postgres-Core/MaplessPostgresClient.class.st b/src/Mapless-Postgres/MaplessPostgresClient.class.st similarity index 99% rename from src/Mapless-Postgres-Core/MaplessPostgresClient.class.st rename to src/Mapless-Postgres/MaplessPostgresClient.class.st index 6878a137..9e78d4f1 100644 --- a/src/Mapless-Postgres-Core/MaplessPostgresClient.class.st +++ b/src/Mapless-Postgres/MaplessPostgresClient.class.st @@ -8,7 +8,7 @@ Class { #instVars : [ 'postgresClient' ], - #category : #'Mapless-Postgres-Core-Connections' + #category : #'Mapless-Postgres-Connections' } { #category : #accessing } diff --git a/src/Mapless-Postgres-Core/MaplessPostgresCurrentClient.class.st b/src/Mapless-Postgres/MaplessPostgresCurrentClient.class.st similarity index 62% rename from src/Mapless-Postgres-Core/MaplessPostgresCurrentClient.class.st rename to src/Mapless-Postgres/MaplessPostgresCurrentClient.class.st index c81c8f88..7e42ee24 100644 --- a/src/Mapless-Postgres-Core/MaplessPostgresCurrentClient.class.st +++ b/src/Mapless-Postgres/MaplessPostgresCurrentClient.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessPostgresCurrentClient, #superclass : #DynamicVariable, - #category : #'Mapless-Postgres-Core-Connections' + #category : #'Mapless-Postgres-Connections' } diff --git a/src/Mapless-Postgres-Core/MaplessPostgresRepository.class.st b/src/Mapless-Postgres/MaplessPostgresRepository.class.st similarity index 99% rename from src/Mapless-Postgres-Core/MaplessPostgresRepository.class.st rename to src/Mapless-Postgres/MaplessPostgresRepository.class.st index 22778cc4..73e3c382 100644 --- a/src/Mapless-Postgres-Core/MaplessPostgresRepository.class.st +++ b/src/Mapless-Postgres/MaplessPostgresRepository.class.st @@ -4,7 +4,7 @@ I prodvide mapless repository access using a PostgreSQL backend. Class { #name : #MaplessPostgresRepository, #superclass : #MaplessRepository, - #category : #'Mapless-Postgres-Core-Connections' + #category : #'Mapless-Postgres-Connections' } { #category : #actions } diff --git a/src/Mapless-Postgres-Core/MaplessStandalonePostgresPool.class.st b/src/Mapless-Postgres/MaplessStandalonePostgresPool.class.st similarity index 99% rename from src/Mapless-Postgres-Core/MaplessStandalonePostgresPool.class.st rename to src/Mapless-Postgres/MaplessStandalonePostgresPool.class.st index f601fb27..92d5bd83 100644 --- a/src/Mapless-Postgres-Core/MaplessStandalonePostgresPool.class.st +++ b/src/Mapless-Postgres/MaplessStandalonePostgresPool.class.st @@ -9,7 +9,7 @@ Class { 'clientsMutex', 'maxClients' ], - #category : #'Mapless-Postgres-Core-Connections' + #category : #'Mapless-Postgres-Connections' } { #category : #'instance creation' } diff --git a/src/Mapless-Postgres/package.st b/src/Mapless-Postgres/package.st new file mode 100644 index 00000000..aca694ac --- /dev/null +++ b/src/Mapless-Postgres/package.st @@ -0,0 +1 @@ +Package { #name : #'Mapless-Postgres' } diff --git a/src/Mapless-Redis-Observer-Tests/MaplessRedisObserverTest.class.st b/src/Mapless-Redis-Observer-Tests/MaplessRedisObserverTest.class.st index ff42898d..f3f9b6a4 100644 --- a/src/Mapless-Redis-Observer-Tests/MaplessRedisObserverTest.class.st +++ b/src/Mapless-Redis-Observer-Tests/MaplessRedisObserverTest.class.st @@ -169,9 +169,10 @@ MaplessRedisObserverTest >> testReactsToObservedPubsubEventWithOneLocalArgument with: 42. self deny: valued. self assert: receivedArguments isNil. + 200 milliSeconds asDelay wait. task2 := repository findOne: SampleTask atId: task1 id. task2 publish: #doTheThing. - 5 milliSeconds asDelay wait. + 200 milliSeconds asDelay wait. self assert: valued. self assert: receivedArguments notNil. self assert: receivedArguments equals: 42 diff --git a/src/Mapless-Redis-Tests/MaplessRedisPoolTest.class.st b/src/Mapless-Redis-Tests/MaplessRedisPoolTest.class.st index 735c3523..e660c0c2 100644 --- a/src/Mapless-Redis-Tests/MaplessRedisPoolTest.class.st +++ b/src/Mapless-Redis-Tests/MaplessRedisPoolTest.class.st @@ -30,9 +30,10 @@ MaplessRedisPoolTest >> testSubscribe [ self shouldnt: [ pool subscribe: #testing callback: reaction ] raise: Error. + 120 milliSeconds asDelay wait. self deny: valued. pool publish: #testing message: 'answer'. - 30 milliSeconds asDelay wait. + 120 milliSeconds asDelay wait. self assert: valued ] @@ -53,8 +54,9 @@ MaplessRedisPoolTest >> testUnsubscribe [ valued := false. pool unsubscribe: #testing. + 200 milliSeconds asDelay wait. pool publish: #testing message: 'answer'. - 30 milliSeconds asDelay wait. + 200 milliSeconds asDelay wait. self deny: valued. ] diff --git a/src/Mapless-Redis-Tests/MaplessRedisTest.class.st b/src/Mapless-Redis-Tests/MaplessRedisTest.class.st index 813d1e8f..81fb4642 100644 --- a/src/Mapless-Redis-Tests/MaplessRedisTest.class.st +++ b/src/Mapless-Redis-Tests/MaplessRedisTest.class.st @@ -24,13 +24,6 @@ MaplessRedisTest >> basicNewRepository [ using: MaplessTrivialResolver new ] -{ #category : #tests } -MaplessRedisTest >> newDummyPersonNamed: aString [ - ^ DummyPerson new - firstName: aString; - yourself -] - { #category : #actions } MaplessRedisTest >> newRepository [ | accessor | @@ -42,6 +35,13 @@ MaplessRedisTest >> newRepository [ using: MaplessTrivialResolver new ] +{ #category : #tests } +MaplessRedisTest >> newSamplePersonNamed: aString [ + ^ SamplePerson new + firstName: aString; + yourself +] + { #category : #'setUp-tearDown' } MaplessRedisTest >> setUp [ super setUp. @@ -74,10 +74,10 @@ MaplessRedisTest >> testComposedAccess [ | user guy | repository := self newRepository. - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -85,22 +85,22 @@ MaplessRedisTest >> testComposedAccess [ repository save: guy. repository save: user. self - assert: (repository findOne: DummyPerson atId: guy id) firstName + assert: (repository findOne: SamplePerson atId: guy id) firstName equals: 'john'. self - assert: (repository findOne: DummyUser atId: user id) person class + assert: (repository findOne: SampleUser atId: user id) person class equals: MaplessReference. self - assert: (repository findOne: DummyUser atId: user id) completeName + assert: (repository findOne: SampleUser atId: user id) completeName equals: 'john q'. self - assert: (repository findOne: DummyUser atId: user id) person model class - equals: DummyPerson. + assert: (repository findOne: SampleUser atId: user id) person model class + equals: SamplePerson. self - assert: (repository findOne: DummyUser atId: user id) person firstName + assert: (repository findOne: SampleUser atId: user id) person firstName equals: 'john'. self - assert: (repository findOne: DummyUser atId: user id) person lastName + assert: (repository findOne: SampleUser atId: user id) person lastName equals: 'q' ] @@ -113,10 +113,10 @@ MaplessRedisTest >> testComposedDelete [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -142,10 +142,10 @@ MaplessRedisTest >> testComposedDestroy [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -155,26 +155,26 @@ MaplessRedisTest >> testComposedDestroy [ self assert: (users - allSatisfy: [ :user | (repository existsId: user person id of: DummyPerson) not ]). + allSatisfy: [ :user | (repository existsId: user person id of: SamplePerson) not ]). self assert: (users - allSatisfy: [ :user | repository existsId: user id of: DummyUser ]). + allSatisfy: [ :user | repository existsId: user id of: SampleUser ]). users do: [ :user | repository destroy: user ]. self assert: (users - allSatisfy: [ :user | (repository existsId: user id of: DummyUser) not ]) + allSatisfy: [ :user | (repository existsId: user id of: SampleUser) not ]) ] { #category : #tests } MaplessRedisTest >> testComposedResaveAndLoad [ | user guy loaded | repository := self newRepository. - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'John'; lastName: 'W'; yourself. @@ -184,19 +184,19 @@ MaplessRedisTest >> testComposedResaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded person firstName equals: 'John'. loaded person lastName: 'wayne'. repository save: loaded person. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded person lastName equals: 'wayne'. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded person firstName equals: 'John'. loaded person lastName: 'Wayne'. repository save: loaded person. loaded username: 'johnw'. repository save: loaded. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded username equals: 'johnw'. self assert: loaded person firstName equals: 'John' ] @@ -205,10 +205,10 @@ MaplessRedisTest >> testComposedResaveAndLoad [ MaplessRedisTest >> testComposedSave [ | user guy | repository := self newRepository. - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -228,11 +228,11 @@ MaplessRedisTest >> testComposedSave [ MaplessRedisTest >> testComposedSaveAndLoad [ | user guy loaded | repository := self newRepository. - user := DummyUser new + user := SampleUser new createdOn: DateAndTime now; username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new createdOn: DateAndTime now; firstName: 'john'; lastName: 'q'; @@ -247,7 +247,7 @@ MaplessRedisTest >> testComposedSaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded notNil. self assert: loaded createdOn notNil. self assert: loaded modifiedOn notNil. @@ -262,24 +262,24 @@ MaplessRedisTest >> testComposedSaveAndLoad [ self assert: loaded username = 'johnq'. self assert: loaded person firstName = 'john'. self assert: loaded person lastName = 'q'. - self assert: loaded person maplessClassName = DummyPerson name. - self assert: loaded person model class = DummyPerson + self assert: loaded person maplessClassName = SamplePerson name. + self assert: loaded person model class = SamplePerson ] { #category : #tests } MaplessRedisTest >> testComposition [ | user guy | repository := self newRepository. - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. - self assert: (user data at: 'person') class equals: DummyPerson. - self assert: (user data at: 'person') _c equals: #DummyPerson. + self assert: (user data at: 'person') class equals: SamplePerson. + self assert: (user data at: 'person') _c equals: #SamplePerson. self assert: user id isNil. self assert: (user data at: 'person') id isNil. self assert: user completeName equals: 'john q' @@ -292,26 +292,26 @@ MaplessRedisTest >> testCountAll [ repository := self newRepository. users := OrderedCollection new. Character alphabet do: [ :char | - users add: (DummyUser new + users add: (SampleUser new username: char asString; - person: (DummyPerson new + person: (SamplePerson new firstName: char asString; yourself); yourself) ]. - count := repository count: DummyUser. + count := repository count: SampleUser. self assert: count equals: 0. - count := repository count: DummyPerson. + count := repository count: SamplePerson. self assert: count equals: 0. users do: [ :user | repository save: user person ]. users do: [ :user | repository save: user ]. - count := repository count: DummyUser. + count := repository count: SampleUser. - count := repository count: DummyUser. + count := repository count: SampleUser. self assert: count equals: 26. - count := repository count: DummyPerson. + count := repository count: SamplePerson. self assert: count equals: 26 ] @@ -322,25 +322,25 @@ MaplessRedisTest >> testCountSome [ repository := self newRepository. users := OrderedCollection new. Character alphabet do: [ :char | - users add: (DummyUser new + users add: (SampleUser new username: char asString; - person: (DummyPerson new + person: (SamplePerson new firstName: char asString; yourself); yourself) ]. - count := repository count: DummyUser where: 'id:123'. + count := repository count: SampleUser where: 'id:123'. self assert: count equals: 0. - count := repository count: DummyPerson where: 'id:123'. + count := repository count: SamplePerson where: 'id:123'. self assert: count equals: 0. users do: [ :user | repository save: user person ]. users do: [ :user | repository save: user ]. - count := repository count: DummyUser where: 'id:' , users first id. + count := repository count: SampleUser where: 'id:' , users first id. self assert: count equals: 1. count := repository - count: DummyPerson + count: SamplePerson where: 'id:' , users first person id. self assert: count equals: 1 ] @@ -350,13 +350,13 @@ MaplessRedisTest >> testDateAndTime [ | when guy loaded | repository := self newRepository. when := DateAndTime now asUTC. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; createdOn: when; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded createdOn asDate asString = when asDate asString. self assert: loaded createdOn asTime hour = when asTime hour. self assert: loaded createdOn asTime minutes = when asTime minutes. @@ -372,7 +372,7 @@ MaplessRedisTest >> testDelete [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -390,7 +390,7 @@ MaplessRedisTest >> testDestroy [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -399,7 +399,7 @@ MaplessRedisTest >> testDestroy [ self assert: (people - allSatisfy: [ :guy | (repository existsId: guy id of: DummyPerson) not ]) + allSatisfy: [ :guy | (repository existsId: guy id of: SamplePerson) not ]) ] { #category : #tests } @@ -411,16 +411,16 @@ MaplessRedisTest >> testFindAll [ do: [ :char | users add: - (DummyUser new + (SampleUser new username: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. users do: [ :user | repository save: user person ]. users do: [ :user | repository save: user ]. - all := repository findAll: DummyUser. + all := repository findAll: SampleUser. self assert: users size equals: all size. self assert: @@ -436,25 +436,25 @@ MaplessRedisTest >> testFindOneAtId [ repository := self newRepository. users := OrderedCollection new. Character alphabet do: [ :char | - users add: (DummyUser new + users add: (SampleUser new username: char asString; - person: (DummyPerson new + person: (SamplePerson new firstName: char asString; yourself); yourself) ]. users do: [ :user | - found := repository findOne: DummyUser atId: user id. + found := repository findOne: SampleUser atId: user id. self assert: found isNil ]. users do: [ :user | repository save: user person ]. users do: [ :user | repository save: user ]. users do: [ :user | - found := repository findOne: DummyUser atId: user id. + found := repository findOne: SampleUser atId: user id. self assert: found id equals: user id. self assert: found username equals: user username. - found := repository findOne: DummyPerson atId: user person id. + found := repository findOne: SamplePerson atId: user person id. self assert: found id equals: user person id. self assert: found firstName equals: user person firstName ] ] @@ -466,16 +466,16 @@ MaplessRedisTest >> testFindOneWhere [ repository := self newRepository. users := OrderedCollection new. Character alphabet do: [ :char | - users add: (DummyUser new + users add: (SampleUser new username: char asString; - person: (DummyPerson new + person: (SamplePerson new firstName: char asString; yourself); yourself) ]. users do: [ :user | found := repository - findOne: DummyUser + findOne: SampleUser where: ('id:{1}' format: { user id }). self assert: found isNil ]. @@ -483,10 +483,10 @@ MaplessRedisTest >> testFindOneWhere [ users do: [ :user | repository save: user ]. users do: [ :user | - found := repository findOne: DummyUser atId: user id. + found := repository findOne: SampleUser atId: user id. self assert: found id equals: user id. self assert: found username equals: user username. - found := repository findOne: DummyPerson atId: user person id. + found := repository findOne: SamplePerson atId: user person id. self assert: found id equals: user person id. self assert: found firstName equals: user person firstName ] ] @@ -496,18 +496,18 @@ MaplessRedisTest >> testInsert [ | guy all | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. self shouldnt: [ repository save: guy ] raise: Error. - all := repository findAll: DummyPerson. + all := repository findAll: SamplePerson. self assert: all size equals: 1. - repository insert: DummyPerson new. + repository insert: SamplePerson new. - all := repository findAll: DummyPerson. + all := repository findAll: SamplePerson. self assert: all size equals: 2. ] @@ -516,7 +516,7 @@ MaplessRedisTest >> testInsert [ MaplessRedisTest >> testIsUnsaved [ | guy | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -532,35 +532,35 @@ MaplessRedisTest >> testMultipleComposedComposables [ tagsOfTagsOfTags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'is this'; yourself); add: - (DummyTag new + (SampleTag new label: 'multiply'; yourself); add: - (DummyTag new + (SampleTag new label: 'composable?'; yourself); yourself. tagsOfTags add: - (DummyTag new + (SampleTag new label: 'like'; yourself); add: - (DummyTag new + (SampleTag new label: 'really?'; yourself); yourself. tagsOfTagsOfTags add: - (DummyTag new + (SampleTag new label: 'wow'; yourself); add: - (DummyTag new + (SampleTag new label: 'nice'; yourself); yourself. @@ -576,7 +576,7 @@ MaplessRedisTest >> testMultipleComposedComposables [ self shouldnt: [ tags do: [ :e | repository save: e ] ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyTag atId: tags first id. + loaded := repository findOne: SampleTag atId: tags first id. self assert: loaded notNil. self assert: loaded label = 'is this'. self assert: loaded tags isCollection. @@ -596,29 +596,29 @@ MaplessRedisTest >> testMultipleComposedComposables [ MaplessRedisTest >> testMultipleComposedMixedSaveAndLoad [ | guy loaded things | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. guy things: OrderedCollection new. guy things add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); add: - (DummyUser new + (SampleUser new info: 'also this'; yourself); yourself. things := guy things. guy things do: [ :each | repository save: each ]. self shouldnt: [ repository save: guy ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded notNil. self assert: loaded firstName = 'john'. self assert: loaded things isCollection. @@ -626,30 +626,30 @@ MaplessRedisTest >> testMultipleComposedMixedSaveAndLoad [ loaded things do: [ :each | self assert: (things anySatisfy: [ :t | t id = each id ]) ]. loaded unreferenced. - self assert: loaded things first class = DummyTag. - self assert: loaded things second class = DummyTag. - self assert: loaded things third class = DummyUser + self assert: loaded things first class = SampleTag. + self assert: loaded things second class = SampleTag. + self assert: loaded things third class = SampleUser ] { #category : #tests } MaplessRedisTest >> testMultipleComposedSaveAndLoad [ | user guy tags loaded | repository := self newRepository. - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. tags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); yourself. @@ -662,7 +662,7 @@ MaplessRedisTest >> testMultipleComposedSaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded notNil. self assert: loaded username = 'johnq'. self assert: loaded tags isCollection. @@ -691,12 +691,12 @@ MaplessRedisTest >> testNormalizeId [ MaplessRedisTest >> testRemovingExpire [ | guy found howMuchWillItBeThere | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - found := repository findOne: DummyPerson atId: guy id. + found := repository findOne: SamplePerson atId: guy id. self assert: found notNil. repository expires: guy in: 900. howMuchWillItBeThere := repository ttlFor: guy. @@ -705,8 +705,8 @@ MaplessRedisTest >> testRemovingExpire [ howMuchWillItBeThere := repository ttlFor: guy. self assert: (howMuchWillItBeThere = -1 or: [ howMuchWillItBeThere = -2 ]). - 100 milliSeconds wait. - found := repository findOne: DummyPerson atId: guy id. + 200 milliSeconds wait. + found := repository findOne: SamplePerson atId: guy id. self assert: found notNil. ] @@ -715,7 +715,7 @@ MaplessRedisTest >> testRemovingExpire [ MaplessRedisTest >> testSaveSetsID [ | guy | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -734,16 +734,16 @@ MaplessRedisTest >> testSetCurrentDatabase [ MaplessRedisTest >> testSimpleExpire [ | guy found | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - found := repository findOne: DummyPerson atId: guy id. + found := repository findOne: SamplePerson atId: guy id. self assert: found notNil. repository expires: guy in: 50. 60 milliSeconds wait. - found := repository findOne: DummyPerson atId: guy id. + found := repository findOne: SamplePerson atId: guy id. self assert: found isNil. ] @@ -752,7 +752,7 @@ MaplessRedisTest >> testSimpleExpire [ MaplessRedisTest >> testSimpleSave [ | guy | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -763,12 +763,12 @@ MaplessRedisTest >> testSimpleSave [ MaplessRedisTest >> testSimpleSaveAndLoad [ | guy loaded | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded notNil. loaded data keysAndValuesDo: [ :k :v | @@ -780,17 +780,17 @@ MaplessRedisTest >> testSimpleSaveAndLoad [ MaplessRedisTest >> testSimpleSaveAndUpdate [ | guy loaded reloaded | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded firstName equals: 'john'. self deny: loaded remember equals: 'this words'. loaded remember: 'this words'. repository save: loaded. - reloaded := repository findOne: DummyPerson atId: guy id. + reloaded := repository findOne: SamplePerson atId: guy id. self assert: reloaded remember = 'this words' ] @@ -798,7 +798,7 @@ MaplessRedisTest >> testSimpleSaveAndUpdate [ MaplessRedisTest >> testSimpleSaveWithAByteSymbol [ | guy | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; value: #thisByteSymbol; @@ -810,17 +810,17 @@ MaplessRedisTest >> testSimpleSaveWithAByteSymbol [ MaplessRedisTest >> testSubModelsFromReifiedJSON [ | user guy jsonString reified | repository := self newRepository. - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. jsonString := user unreferenced asJSONString. - reified := DummyUser fromJSONString: jsonString in: repository. - self assert: reified person class equals: DummyPerson. + reified := SampleUser fromJSONString: jsonString in: repository. + self assert: reified person class equals: SamplePerson. self assert: reified completeName equals: 'john q' ] @@ -829,20 +829,20 @@ MaplessRedisTest >> testUpdate [ | guy found foundAgain | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. self shouldnt: [ repository save: guy ] raise: Error. - found := repository findOne: DummyPerson atId: guy id. + found := repository findOne: SamplePerson atId: guy id. self assert: found notNil. self assert: found id equals: guy id. self assert: found firstName equals: 'john'. found firstName: 'John'. repository update: found. - foundAgain := repository findOne: DummyPerson atId: guy id. + foundAgain := repository findOne: SamplePerson atId: guy id. self assert: foundAgain firstName equals: 'John' ] @@ -850,15 +850,15 @@ MaplessRedisTest >> testUpdate [ MaplessRedisTest >> testUpdatingExpire [ | guy found howMuchWillItBeThere newerTTL answer | repository := self newRepository. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - found := repository findOne: DummyPerson atId: guy id. + found := repository findOne: SamplePerson atId: guy id. self assert: found notNil. repository expires: guy in: 900. - 60 milliSeconds wait. + 30 milliSeconds asDelay wait. howMuchWillItBeThere := repository ttlFor: guy. self assert: howMuchWillItBeThere > 0. answer := repository expires: guy in: 2500. diff --git a/src/Mapless-SQLite-Core/package.st b/src/Mapless-SQLite-Core/package.st deleted file mode 100644 index 83fe984d..00000000 --- a/src/Mapless-SQLite-Core/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Mapless-SQLite-Core' } diff --git a/src/Mapless-SQLite-Tests/MaplessSQLiteTest.class.st b/src/Mapless-SQLite-Tests/MaplessSQLiteTest.class.st index 9c4459ab..094ef024 100644 --- a/src/Mapless-SQLite-Tests/MaplessSQLiteTest.class.st +++ b/src/Mapless-SQLite-Tests/MaplessSQLiteTest.class.st @@ -30,9 +30,9 @@ MaplessSQLiteTest class >> lastStoredRun [ { #category : #history } MaplessSQLiteTest class >> maplessClasses [ - ^ {DummyPerson. - DummyUser. - DummyTag} + ^ {SamplePerson. + SampleUser. + SampleTag} ] { #category : #accessing } @@ -56,7 +56,7 @@ MaplessSQLiteTest >> resetDatabase [ MaplessSQLiteTest >> savePersonNamed: aString [ repository save: - (DummyPerson new + (SamplePerson new firstName: aString; yourself) ] @@ -84,10 +84,10 @@ MaplessSQLiteTest >> testComposedAccess [ "Test proxies and its on-demand-load and DNU mechanism" | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -95,19 +95,19 @@ MaplessSQLiteTest >> testComposedAccess [ repository save: guy. repository save: user. self - assert: (repository findOne: DummyUser atId: user id) completeName + assert: (repository findOne: SampleUser atId: user id) completeName equals: 'john q'. self - assert: (repository findOne: DummyUser atId: user id) person class + assert: (repository findOne: SampleUser atId: user id) person class equals: MaplessReference. self - assert: (repository findOne: DummyUser atId: user id) person model class - equals: DummyPerson. + assert: (repository findOne: SampleUser atId: user id) person model class + equals: SamplePerson. self - assert: (repository findOne: DummyUser atId: user id) person firstName + assert: (repository findOne: SampleUser atId: user id) person firstName equals: 'john'. self - assert: (repository findOne: DummyUser atId: user id) person lastName + assert: (repository findOne: SampleUser atId: user id) person lastName equals: 'q' ] @@ -119,10 +119,10 @@ MaplessSQLiteTest >> testComposedDelete [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -147,10 +147,10 @@ MaplessSQLiteTest >> testComposedDestroy [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -160,31 +160,31 @@ MaplessSQLiteTest >> testComposedDestroy [ assert: (users allSatisfy: - [ :user | (repository findOne: DummyPerson atId: user person id) notNil ]). + [ :user | (repository findOne: SamplePerson atId: user person id) notNil ]). users do: [ :user | repository destroy: user person ]. self assert: (users allSatisfy: - [ :user | (repository findOne: DummyPerson atId: user person id) isNil ]). + [ :user | (repository findOne: SamplePerson atId: user person id) isNil ]). self assert: (users - allSatisfy: [ :user | (repository findOne: DummyUser atId: user id) notNil ]). + allSatisfy: [ :user | (repository findOne: SampleUser atId: user id) notNil ]). users do: [ :user | repository destroy: user ]. self assert: (users - allSatisfy: [ :user | (repository findOne: DummyUser atId: user id) isNil ]) + allSatisfy: [ :user | (repository findOne: SampleUser atId: user id) isNil ]) ] { #category : #tests } MaplessSQLiteTest >> testComposedSave [ | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -204,11 +204,11 @@ MaplessSQLiteTest >> testComposedSave [ MaplessSQLiteTest >> testComposedSaveAndLoad [ | user guy loaded when | when := DateAndTime now asUTC. - user := DummyUser new + user := SampleUser new createdOn: when; username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new createdOn: when; firstName: 'john'; lastName: 'q'; @@ -223,7 +223,7 @@ MaplessSQLiteTest >> testComposedSaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded notNil. self assert: loaded createdOn notNil. self assert: loaded modifiedOn notNil. @@ -240,24 +240,24 @@ MaplessSQLiteTest >> testComposedSaveAndLoad [ self assert: loaded username = 'johnq'. self assert: loaded person firstName = 'john'. self assert: loaded person lastName = 'q'. - self assert: loaded person maplessClassName = #DummyPerson. - self assert: loaded person model class = DummyPerson + self assert: loaded person maplessClassName = #SamplePerson. + self assert: loaded person model class = SamplePerson ] { #category : #tests } MaplessSQLiteTest >> testComposition [ | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. self assert: (user maplessData at: 'person') class - equals: DummyPerson. + equals: SamplePerson. self assert: user id isNil. self assert: (user maplessData at: 'person') id isNil. self assert: user completeName equals: 'john q' @@ -269,9 +269,9 @@ MaplessSQLiteTest >> testConditionalCount [ | users firstNames sqlCondition | users := OrderedCollection new. Character alphabet do: [ :char | - users add: (DummyUser new + users add: (SampleUser new username: char asString; - person: (DummyPerson new + person: (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -285,7 +285,7 @@ MaplessSQLiteTest >> testConditionalCount [ replaceAll: $" with: $') }. self - assert: (repository count: DummyPerson where: sqlCondition) + assert: (repository count: SamplePerson where: sqlCondition) equals: firstNames size ] @@ -297,17 +297,17 @@ MaplessSQLiteTest >> testCount [ do: [ :char | users add: - (DummyUser new + (SampleUser new username: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. users do: [ :user | repository save: user person ]. users do: [ :user | repository save: user ]. self - assert: (repository count: DummyUser) + assert: (repository count: SampleUser) equals: Character alphabet size ] @@ -319,7 +319,7 @@ MaplessSQLiteTest >> testDelete [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -336,7 +336,7 @@ MaplessSQLiteTest >> testDestroy [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -345,24 +345,24 @@ MaplessSQLiteTest >> testDestroy [ self assert: (people - allSatisfy: [ :guy | (repository findOne: DummyPerson atId: guy id) isNil ]) + allSatisfy: [ :guy | (repository findOne: SamplePerson atId: guy id) isNil ]) ] { #category : #tests } MaplessSQLiteTest >> testExists [ | guy loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - self assert: (repository existsId: guy id of: DummyPerson) + self assert: (repository existsId: guy id of: SamplePerson) ] { #category : #tests } MaplessSQLiteTest >> testIsUnsaved [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -381,35 +381,35 @@ MaplessSQLiteTest >> testMultipleComposedComposables [ tagsOfTagsOfTags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'is this'; yourself); add: - (DummyTag new + (SampleTag new label: 'multiply'; yourself); add: - (DummyTag new + (SampleTag new label: 'composable?'; yourself); yourself. tagsOfTags add: - (DummyTag new + (SampleTag new label: 'like'; yourself); add: - (DummyTag new + (SampleTag new label: 'really?'; yourself); yourself. tagsOfTagsOfTags add: - (DummyTag new + (SampleTag new label: 'wow'; yourself); add: - (DummyTag new + (SampleTag new label: 'nice'; yourself); yourself. @@ -425,7 +425,7 @@ MaplessSQLiteTest >> testMultipleComposedComposables [ self shouldnt: [ tags do: [ :e | repository save: e ] ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyTag atId: tags first id. + loaded := repository findOne: SampleTag atId: tags first id. self assert: loaded notNil. self assert: loaded label = 'is this'. self assert: loaded tags isCollection. @@ -444,29 +444,29 @@ MaplessSQLiteTest >> testMultipleComposedComposables [ { #category : #tests } MaplessSQLiteTest >> testMultipleComposedMixedSaveAndLoad [ | guy things loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. guy things: OrderedCollection new. guy things add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); add: - (DummyUser new + (SampleUser new info: 'also this'; yourself); yourself. things := guy things. guy things do: [ :each | repository save: each ]. self shouldnt: [ repository save: guy ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded notNil. self assert: loaded firstName = 'john'. self assert: loaded things isCollection. @@ -474,29 +474,29 @@ MaplessSQLiteTest >> testMultipleComposedMixedSaveAndLoad [ loaded things do: [ :each | self assert: (things anySatisfy: [ :t | t id = each id ]) ]. loaded unreferenced. - self assert: loaded things first class = DummyTag. - self assert: loaded things second class = DummyTag. - self assert: loaded things third class = DummyUser + self assert: loaded things first class = SampleTag. + self assert: loaded things second class = SampleTag. + self assert: loaded things third class = SampleUser ] { #category : #tests } MaplessSQLiteTest >> testMultipleComposedSaveAndLoad [ | user guy tags loaded | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. tags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); yourself. @@ -509,7 +509,7 @@ MaplessSQLiteTest >> testMultipleComposedSaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded notNil. self assert: loaded username = 'johnq'. self assert: loaded tags isCollection. @@ -525,9 +525,9 @@ MaplessSQLiteTest >> testQueryUsers [ | users | users := OrderedCollection new. Character alphabet do: [ :char | - users add: (DummyUser new + users add: (SampleUser new username: char asString; - person: (DummyPerson new + person: (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -535,7 +535,7 @@ MaplessSQLiteTest >> testQueryUsers [ users do: [ :user | repository save: user ]. self assert: (Character alphabet allSatisfy: [ :char | (repository - findOne: DummyUser + findOne: SampleUser where: ('json_extract(maplessData,"$.username") = {1}' format: { char asString printString })) notNil ]) ] @@ -543,7 +543,7 @@ MaplessSQLiteTest >> testQueryUsers [ { #category : #tests } MaplessSQLiteTest >> testSaveSetsID [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -556,7 +556,7 @@ MaplessSQLiteTest >> testSaveSetsID [ { #category : #tests } MaplessSQLiteTest >> testSimpleSave [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -566,12 +566,12 @@ MaplessSQLiteTest >> testSimpleSave [ { #category : #tests } MaplessSQLiteTest >> testSimpleSaveAndLoad [ | guy loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded notNil. loaded modifiedOn: nil. guy modifiedOn: nil. @@ -584,38 +584,38 @@ MaplessSQLiteTest >> testSimpleSaveAndLoad [ { #category : #tests } MaplessSQLiteTest >> testSimpleSaveAndUpdate [ | guy loaded reloaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded firstName = 'john'. self deny: loaded remember = 'this words'. loaded firstName: loaded firstName capitalized. loaded remember: 'this words'. repository save: loaded. - reloaded := repository findOne: DummyPerson atId: guy id. + reloaded := repository findOne: SamplePerson atId: guy id. self assert: reloaded remember = 'this words' ] { #category : #tests } MaplessSQLiteTest >> testSubModelsFromReifiedJSON [ | user guy jsonString reified loaded | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. repository save: guy. repository save: user. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. jsonString := loaded unreferenced asJSONString. - reified := DummyUser fromJSONString: jsonString in: repository. - self assert: reified person class equals: DummyPerson. + reified := SampleUser fromJSONString: jsonString in: repository. + self assert: reified person class equals: SamplePerson. self assert: reified completeName equals: 'john q' ] @@ -625,13 +625,13 @@ MaplessSQLiteTest >> testTruncate [ | people | people := OrderedCollection new. Character alphabet do: [ :char | - people add: (DummyPerson new + people add: (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. self assert: (people allSatisfy: [ :guy | guy isDeleted not ]). - self assert: (repository count: DummyPerson) equals: 26. - repository withClientDo: [ :client | client truncateMapless: DummyPerson ]. - self assert: (repository count: DummyPerson) equals: 0. + self assert: (repository count: SamplePerson) equals: 26. + repository withClientDo: [ :client | client truncateMapless: SamplePerson ]. + self assert: (repository count: SamplePerson) equals: 0. ] diff --git a/src/Mapless-SQLite-Core/MaplessSQLiteClient.class.st b/src/Mapless-SQLite/MaplessSQLiteClient.class.st similarity index 99% rename from src/Mapless-SQLite-Core/MaplessSQLiteClient.class.st rename to src/Mapless-SQLite/MaplessSQLiteClient.class.st index cf014bbd..08481ada 100644 --- a/src/Mapless-SQLite-Core/MaplessSQLiteClient.class.st +++ b/src/Mapless-SQLite/MaplessSQLiteClient.class.st @@ -7,7 +7,7 @@ Class { #instVars : [ 'sqliteClient' ], - #category : #'Mapless-SQLite-Core' + #category : #'Mapless-SQLite' } { #category : #accessing } diff --git a/src/Mapless-SQLite-Core/MaplessSQLiteCurrentClient.class.st b/src/Mapless-SQLite/MaplessSQLiteCurrentClient.class.st similarity index 80% rename from src/Mapless-SQLite-Core/MaplessSQLiteCurrentClient.class.st rename to src/Mapless-SQLite/MaplessSQLiteCurrentClient.class.st index 5ed31023..dc434019 100644 --- a/src/Mapless-SQLite-Core/MaplessSQLiteCurrentClient.class.st +++ b/src/Mapless-SQLite/MaplessSQLiteCurrentClient.class.st @@ -4,5 +4,5 @@ I hold the current SQLite client in use for this thread (if any) Class { #name : #MaplessSQLiteCurrentClient, #superclass : #DynamicVariable, - #category : #'Mapless-SQLite-Core' + #category : #'Mapless-SQLite' } diff --git a/src/Mapless-SQLite-Core/MaplessSQLitePool.class.st b/src/Mapless-SQLite/MaplessSQLitePool.class.st similarity index 99% rename from src/Mapless-SQLite-Core/MaplessSQLitePool.class.st rename to src/Mapless-SQLite/MaplessSQLitePool.class.st index cc844520..6d2d16a8 100644 --- a/src/Mapless-SQLite-Core/MaplessSQLitePool.class.st +++ b/src/Mapless-SQLite/MaplessSQLitePool.class.st @@ -13,7 +13,7 @@ Class { 'maxClients', 'databaseFilenameOrKeyword' ], - #category : #'Mapless-SQLite-Core' + #category : #'Mapless-SQLite' } { #category : #'instance creation' } diff --git a/src/Mapless-SQLite-Core/MaplessSQLiteRepository.class.st b/src/Mapless-SQLite/MaplessSQLiteRepository.class.st similarity index 99% rename from src/Mapless-SQLite-Core/MaplessSQLiteRepository.class.st rename to src/Mapless-SQLite/MaplessSQLiteRepository.class.st index 7af337a3..4ec733a3 100644 --- a/src/Mapless-SQLite-Core/MaplessSQLiteRepository.class.st +++ b/src/Mapless-SQLite/MaplessSQLiteRepository.class.st @@ -4,7 +4,7 @@ I give access to SQLite Class { #name : #MaplessSQLiteRepository, #superclass : #MaplessRepository, - #category : #'Mapless-SQLite-Core' + #category : #'Mapless-SQLite' } { #category : #'instance creation' } diff --git a/src/Mapless-SQLite/package.st b/src/Mapless-SQLite/package.st new file mode 100644 index 00000000..f99d875f --- /dev/null +++ b/src/Mapless-SQLite/package.st @@ -0,0 +1 @@ +Package { #name : #'Mapless-SQLite' } diff --git a/src/Mapless-Tests-Base/DummyPerson.class.st b/src/Mapless-Tests-Base/DummyPerson.class.st deleted file mode 100644 index e1489c3f..00000000 --- a/src/Mapless-Tests-Base/DummyPerson.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #DummyPerson, - #superclass : #Mapless, - #category : #'Mapless-Tests-Base-Samples' -} diff --git a/src/Mapless-Tests-Base/DummyTag.class.st b/src/Mapless-Tests-Base/DummyTag.class.st deleted file mode 100644 index d0b71433..00000000 --- a/src/Mapless-Tests-Base/DummyTag.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #DummyTag, - #superclass : #Mapless, - #category : #'Mapless-Tests-Base-Samples' -} diff --git a/src/Mapless-Tests-Base/MaplessResourcesTest.class.st b/src/Mapless-Tests-Base/MaplessResourcesTest.class.st deleted file mode 100644 index 52ab18e0..00000000 --- a/src/Mapless-Tests-Base/MaplessResourcesTest.class.st +++ /dev/null @@ -1,101 +0,0 @@ -Class { - #name : #MaplessResourcesTest, - #superclass : #MaplessTestCase, - #category : #'Mapless-Tests-Base-Tests' -} - -{ #category : #tests } -MaplessResourcesTest >> test11And44And44Chance [ - | wr n1 n2 i j latest k n3 | - i := 0. - j := 0. - k := 0. - wr := MaplessWeightedRandomPolicy new. - n1 := MaplessWeightedNode new - weight: 0.5; - value: 'url1'; - yourself. - n2 := MaplessWeightedNode new - weight: 2; - value: 'url2'; - yourself. - n3 := MaplessWeightedNode new - weight: 2; - value: 'url3'; - yourself. - wr - addNode: n1; - addNode: n2; - addNode: n3; - yourself. - 10000 - timesRepeat: [ latest := wr next. - latest value = 'url1' - ifTrue: [ i := i + 1 ]. - latest value = 'url2' - ifTrue: [ j := j + 1 ]. - latest value = 'url3' - ifTrue: [ k := k + 1 ] ]. - self assert: i > 1000. - self assert: i < 1200. - self assert: j > 4200. - self assert: j < 4600. - self assert: k > 4200. - self assert: k < 4600 -] - -{ #category : #tests } -MaplessResourcesTest >> test30And70Chance [ - | wr n1 n2 i j latest | - i := 0. - j := 0. - wr := MaplessWeightedRandomPolicy new. - n1 := MaplessWeightedNode new - weight: 30; - value: 'url1'; - yourself. - n2 := MaplessWeightedNode new - weight: 70; - value: 'url2'; - yourself. - wr - addNode: n1; - addNode: n2; - yourself. - 10000 - timesRepeat: [ latest := wr next. - latest value = 'url1' - ifTrue: [ i := i + 1 ]. - latest value = 'url2' - ifTrue: [ j := j + 1 ] ]. - self assert: i > 2800. - self assert: j > 6800 -] - -{ #category : #tests } -MaplessResourcesTest >> testHalfHalfChance [ - | wr n1 n2 i j latest | - i := 0. - j := 0. - wr := MaplessWeightedRandomPolicy new. - n1 := MaplessWeightedNode new - weight: 2; - value: 'url1'; - yourself. - n2 := MaplessWeightedNode new - weight: 2; - value: 'url2'; - yourself. - wr - addNode: n1; - addNode: n2; - yourself. - 10000 - timesRepeat: [ latest := wr next. - latest value = 'url1' - ifTrue: [ i := i + 1 ]. - latest value = 'url2' - ifTrue: [ j := j + 1 ] ]. - self assert: i > 4800. - self assert: j > 4800 -] diff --git a/src/Mapless-Tests-Base/MaplessTestCase.class.st b/src/Mapless-Tests-Base/MaplessTestCase.class.st deleted file mode 100644 index b6417ec9..00000000 --- a/src/Mapless-Tests-Base/MaplessTestCase.class.st +++ /dev/null @@ -1,26 +0,0 @@ -Class { - #name : #MaplessTestCase, - #superclass : #TestCase, - #category : #'Mapless-Tests-Base-Tests' -} - -{ #category : #tests } -MaplessTestCase >> testGetterReturn [ - | guy | - guy := DummyPerson new. - self assert: guy firstName isNil. - guy firstName: 'John'. - self assert: guy firstName notNil. - self assert: guy firstName equals: 'John' -] - -{ #category : #tests } -MaplessTestCase >> testSetterReturn [ - | guy set | - guy := DummyPerson new. - self assert: guy firstName isNil. - set := guy firstName: 'John'. - self assert: set equals: guy. - self assert: guy firstName notNil. - self assert: guy firstName equals: 'John' -] diff --git a/src/Mapless-Tests-Base/package.st b/src/Mapless-Tests-Base/package.st deleted file mode 100644 index 4c5cb803..00000000 --- a/src/Mapless-Tests-Base/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Mapless-Tests-Base' } diff --git a/src/Mapless-Tests/MaplessResourcesTest.class.st b/src/Mapless-Tests/MaplessResourcesTest.class.st new file mode 100644 index 00000000..83420a30 --- /dev/null +++ b/src/Mapless-Tests/MaplessResourcesTest.class.st @@ -0,0 +1,188 @@ +Class { + #name : #MaplessResourcesTest, + #superclass : #MaplessTestCase, + #category : #'Mapless-Tests-Tests' +} + +{ #category : #tests } +MaplessResourcesTest >> test11And44And44Chance [ + | wr n1 n2 i j latest k n3 | + i := 0. + j := 0. + k := 0. + wr := MaplessWeightedRandomPolicy new. + n1 := MaplessWeightedNode new + weight: 0.5; + value: 'url1'; + yourself. + n2 := MaplessWeightedNode new + weight: 2; + value: 'url2'; + yourself. + n3 := MaplessWeightedNode new + weight: 2; + value: 'url3'; + yourself. + wr + addNode: n1; + addNode: n2; + addNode: n3. + 10000 + timesRepeat: [ latest := wr next. + latest value = 'url1' + ifTrue: [ i := i + 1 ]. + latest value = 'url2' + ifTrue: [ j := j + 1 ]. + latest value = 'url3' + ifTrue: [ k := k + 1 ] ]. + self assert: i > 1000. + self assert: i < 1200. + self assert: j > 4200. + self assert: j < 4600. + self assert: k > 4200. + self assert: k < 4600 +] + +{ #category : #tests } +MaplessResourcesTest >> test30And70Chance [ + | wr n1 n2 i j latest | + i := 0. + j := 0. + wr := MaplessWeightedRandomPolicy new. + n1 := MaplessWeightedNode new + weight: 30; + value: 'url1'; + yourself. + n2 := MaplessWeightedNode new + weight: 70; + value: 'url2'; + yourself. + wr + addNode: n1; + addNode: n2. + 10000 + timesRepeat: [ latest := wr next. + latest value = 'url1' + ifTrue: [ i := i + 1 ]. + latest value = 'url2' + ifTrue: [ j := j + 1 ] ]. + self assert: i > 2800. + self assert: j > 6800 +] + +{ #category : #tests } +MaplessResourcesTest >> testAddNodes [ + + | wr n1 n2 | + wr := MaplessWeightedRandomPolicy new. + n1 := MaplessWeightedNode new + weight: 30; + value: 'url1'; + yourself. + n2 := MaplessWeightedNode new + weight: 70; + value: 'url2'; + yourself. + wr nodes: { + n1. + n2 }. + + self assert: wr nodes first equals: n1. + self assert: wr nodes second equals: n2 +] + +{ #category : #tests } +MaplessResourcesTest >> testChangeWeightedNodeWeight [ + + | n1 | + n1 := MaplessWeightedNode new + weight: 0.5; + value: 'url1'; + yourself. + + self assert: n1 weight equals: 0.5. + + n1 weight: 0.75. + self deny: n1 weight equals: 0.5. + self assert: n1 weight equals: 0.75 +] + +{ #category : #tests } +MaplessResourcesTest >> testHalfHalfChance [ + | wr n1 n2 i j latest | + i := 0. + j := 0. + wr := MaplessWeightedRandomPolicy new. + n1 := MaplessWeightedNode new + weight: 2; + value: 'url1'; + yourself. + n2 := MaplessWeightedNode new + weight: 2; + value: 'url2'; + yourself. + wr + addNode: n1; + addNode: n2. + 10000 + timesRepeat: [ latest := wr next. + latest value = 'url1' + ifTrue: [ i := i + 1 ]. + latest value = 'url2' + ifTrue: [ j := j + 1 ] ]. + self assert: i > 4800. + self assert: j > 4800 +] + +{ #category : #tests } +MaplessResourcesTest >> testPrintsWeightedNodeInAUsefulWay [ + + | n1 | + n1 := MaplessWeightedNode new + weight: 0.5; + value: 'url1'; + yourself. + + self assert: n1 asString equals: 'a MaplessWeightedNode(0.5@url1)' +] + +{ #category : #tests } +MaplessResourcesTest >> testRandom [ + + | wr n1 n2 thisOne | + wr := MaplessWeightedRandomPolicy seed: 1000. + n1 := MaplessWeightedNode new + weight: 30; + value: 'url1'; + yourself. + n2 := MaplessWeightedNode new + weight: 70; + value: 'url2'; + yourself. + wr nodes: { + n1. + n2 }. + wr recalculateWeight. + thisOne := wr next. + self assert: (thisOne = n1 or: [ thisOne = n2 ]) +] + +{ #category : #tests } +MaplessResourcesTest >> testWeights [ + + | wr n1 n2 | + wr := MaplessWeightedRandomPolicy seed: 1000. + n1 := MaplessWeightedNode new + weight: 30; + value: 'url1'; + yourself. + n2 := MaplessWeightedNode new + weight: 70; + value: 'url2'; + yourself. + wr nodes: { + n1. + n2 }. + wr recalculateWeight. + self assert: wr totalWeight equals: 100 +] diff --git a/src/Mapless-Tests/MaplessTestCase.class.st b/src/Mapless-Tests/MaplessTestCase.class.st new file mode 100644 index 00000000..430f8ff6 --- /dev/null +++ b/src/Mapless-Tests/MaplessTestCase.class.st @@ -0,0 +1,101 @@ +Class { + #name : #MaplessTestCase, + #superclass : #TestCase, + #category : #'Mapless-Tests-Tests' +} + +{ #category : #tests } +MaplessTestCase >> testAbstract [ + + self assert: Mapless isAbstract. + self deny: SamplePerson isAbstract +] + +{ #category : #tests } +MaplessTestCase >> testDeprecated [ + + self deny: SamplePerson isDeprecated +] + +{ #category : #tests } +MaplessTestCase >> testGetterReturn [ + | guy | + guy := SamplePerson new. + self assert: guy firstName isNil. + guy firstName: 'John'. + self assert: guy firstName notNil. + self assert: guy firstName equals: 'John' +] + +{ #category : #tests } +MaplessTestCase >> testMaplessClass [ + + self assert: Mapless maplessClass equals: Mapless. + self assert: SamplePerson maplessClass equals: SamplePerson +] + +{ #category : #tests } +MaplessTestCase >> testMaplessErrorDefaultAction [ + + self + should: [ MaplessError signal: 'mmmmmmmmm...' ] + raise: MaplessError. + + self should: [ MaplessError new defaultAction ] raise: UnhandledError +] + +{ #category : #tests } +MaplessTestCase >> testPoolBasics [ + + | pool | + pool := MaplessAbstractPool + hostname: '1' + port: 2 + username: '3' + password: '4'. + + self assert: pool hostname equals: '1'. + self assert: pool port equals: 2. + self assert: pool username equals: '3'. + self assert: pool password equals: '4'. + + pool := MaplessAbstractPool hostname: '1' port: 2. + + self assert: pool hostname equals: '1'. + self assert: pool port equals: 2. + + self shouldnt: [ pool logNewClient: 42 ] raise: Error. + + self deny: pool hasHealthChecker +] + +{ #category : #tests } +MaplessTestCase >> testSanitizeProperties [ + + | guy | + guy := SamplePerson new. + self assert: guy firstName isNil. + guy + firstName: 'John'; + lastName: 'Carpenter'; + phone: '1234'. + + self assert: guy firstName notNil. + self assert: guy firstName equals: 'John'. + self deny: guy phone isNil. + guy sanitize: { #phone }. + self deny: guy phone notNil. + self assert: guy firstName equals: 'John'. + +] + +{ #category : #tests } +MaplessTestCase >> testSetterReturn [ + | guy set | + guy := SamplePerson new. + self assert: guy firstName isNil. + set := guy firstName: 'John'. + self assert: set equals: guy. + self assert: guy firstName notNil. + self assert: guy firstName equals: 'John' +] diff --git a/src/Mapless-Tests/SamplePerson.class.st b/src/Mapless-Tests/SamplePerson.class.st new file mode 100644 index 00000000..e785af9b --- /dev/null +++ b/src/Mapless-Tests/SamplePerson.class.st @@ -0,0 +1,21 @@ +Class { + #name : #SamplePerson, + #superclass : #Mapless, + #category : #'Mapless-Tests-Samples' +} + +{ #category : #hooks } +SamplePerson >> onAfterDestroy [ + + super onAfterDestroy. + + self recentlyDestroyed: true +] + +{ #category : #hooks } +SamplePerson >> onAfterSave [ + + super onAfterSave. + + self recentlySaved: true +] diff --git a/src/Mapless-Tests-Base/DummyPersonInteroperating.class.st b/src/Mapless-Tests/SamplePersonInteroperating.class.st similarity index 63% rename from src/Mapless-Tests-Base/DummyPersonInteroperating.class.st rename to src/Mapless-Tests/SamplePersonInteroperating.class.st index 76366ddd..b62d143f 100644 --- a/src/Mapless-Tests-Base/DummyPersonInteroperating.class.st +++ b/src/Mapless-Tests/SamplePersonInteroperating.class.st @@ -2,7 +2,7 @@ I'm a DummyPerson mapless that is meant to be used interoperating with objects persisted in Voyage. " Class { - #name : #DummyPersonInteroperating, + #name : #SamplePersonInteroperating, #superclass : #Mapless, - #category : #'Mapless-Tests-Base-Samples' + #category : #'Mapless-Tests-Samples' } diff --git a/src/Mapless-Tests/SampleTag.class.st b/src/Mapless-Tests/SampleTag.class.st new file mode 100644 index 00000000..a33ca30c --- /dev/null +++ b/src/Mapless-Tests/SampleTag.class.st @@ -0,0 +1,5 @@ +Class { + #name : #SampleTag, + #superclass : #Mapless, + #category : #'Mapless-Tests-Samples' +} diff --git a/src/Mapless-Tests-Base/DummyUser.class.st b/src/Mapless-Tests/SampleUser.class.st similarity index 69% rename from src/Mapless-Tests-Base/DummyUser.class.st rename to src/Mapless-Tests/SampleUser.class.st index e8e798fa..8ddc19fe 100644 --- a/src/Mapless-Tests-Base/DummyUser.class.st +++ b/src/Mapless-Tests/SampleUser.class.st @@ -1,89 +1,89 @@ Class { - #name : #DummyUser, + #name : #SampleUser, #superclass : #Mapless, - #category : #'Mapless-Tests-Base-Samples' + #category : #'Mapless-Tests-Samples' } { #category : #'as yet unclassified' } -DummyUser class >> findUsername: anUsername [ +SampleUser class >> findUsername: anUsername [ ^ self getRepository findOne: self where: {('username' -> anUsername)} asDictionary ] { #category : #accessing } -DummyUser >> completeName [ +SampleUser >> completeName [ ^ self person firstName , ' ' , self person lastName ] { #category : #hooks } -DummyUser >> onAfterDelete [ +SampleUser >> onAfterDelete [ super onAfterDelete. self afterDelete: true ] { #category : #hooks } -DummyUser >> onAfterDestroy [ +SampleUser >> onAfterDestroy [ super onAfterDestroy. self afterDestroy: true ] { #category : #hooks } -DummyUser >> onAfterInsert [ +SampleUser >> onAfterInsert [ super onAfterInsert. self afterInsert: true ] { #category : #hooks } -DummyUser >> onAfterSave [ +SampleUser >> onAfterSave [ super onAfterSave. self afterSave: true ] { #category : #hooks } -DummyUser >> onAfterUpdate [ +SampleUser >> onAfterUpdate [ super onAfterUpdate. self afterUpdate: true ] { #category : #hooks } -DummyUser >> onAfterUpsert [ +SampleUser >> onAfterUpsert [ super onAfterUpsert. self afterUpsert: true ] { #category : #hooks } -DummyUser >> onBeforeDelete [ +SampleUser >> onBeforeDelete [ super onBeforeDelete. self beforeDelete: true ] { #category : #hooks } -DummyUser >> onBeforeDestroy [ +SampleUser >> onBeforeDestroy [ super onBeforeDestroy. self beforeDestroy: true ] { #category : #hooks } -DummyUser >> onBeforeInsert [ +SampleUser >> onBeforeInsert [ super onBeforeInsert. self beforeInsert: true ] { #category : #hooks } -DummyUser >> onBeforeSave [ +SampleUser >> onBeforeSave [ super onBeforeSave. self beforeSave: true ] { #category : #hooks } -DummyUser >> onBeforeUpdate [ +SampleUser >> onBeforeUpdate [ super onBeforeUpdate. self beforeUpdate: true ] { #category : #hooks } -DummyUser >> onBeforeUpsert [ +SampleUser >> onBeforeUpsert [ super onBeforeUpsert. self beforeUpsert: true ] diff --git a/src/Mapless-Tests-Base/DummyUserInteroperating.class.st b/src/Mapless-Tests/SampleUserInteroperating.class.st similarity index 63% rename from src/Mapless-Tests-Base/DummyUserInteroperating.class.st rename to src/Mapless-Tests/SampleUserInteroperating.class.st index 0a862857..8a82b3cb 100644 --- a/src/Mapless-Tests-Base/DummyUserInteroperating.class.st +++ b/src/Mapless-Tests/SampleUserInteroperating.class.st @@ -2,7 +2,7 @@ I'm a DummyUser mapless that is meant to be used interoperating with objects persisted in Voyage. " Class { - #name : #DummyUserInteroperating, + #name : #SampleUserInteroperating, #superclass : #Mapless, - #category : #'Mapless-Tests-Base-Samples' + #category : #'Mapless-Tests-Samples' } diff --git a/src/Mapless-Tests/package.st b/src/Mapless-Tests/package.st new file mode 100644 index 00000000..9c6b109b --- /dev/null +++ b/src/Mapless-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'Mapless-Tests' } diff --git a/src/Mapless-UnQLite-Core/package.st b/src/Mapless-UnQLite-Core/package.st deleted file mode 100644 index e00a4c33..00000000 --- a/src/Mapless-UnQLite-Core/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Mapless-UnQLite-Core' } diff --git a/src/Mapless-UnQLite-Tests/MaplessUnQLiteTest.class.st b/src/Mapless-UnQLite-Tests/MaplessUnQLiteTest.class.st index fd6ec588..5e9f4e55 100644 --- a/src/Mapless-UnQLite-Tests/MaplessUnQLiteTest.class.st +++ b/src/Mapless-UnQLite-Tests/MaplessUnQLiteTest.class.st @@ -3,7 +3,7 @@ Cover basic functionality " Class { #name : #MaplessUnQLiteTest, - #superclass : #MaplessTestCase, + #superclass : #AnObsoleteMaplessTestCase, #instVars : [ 'repository' ], @@ -12,9 +12,9 @@ Class { { #category : #history } MaplessUnQLiteTest class >> maplessClasses [ - ^ {DummyPerson. - DummyUser. - DummyTag} + ^ {SamplePerson. + SampleUser. + SampleTag} ] { #category : #actions } @@ -26,7 +26,7 @@ MaplessUnQLiteTest >> dropDatabase: aDatabaseFileName [ MaplessUnQLiteTest >> savePersonNamed: aString [ repository save: - (DummyPerson new + (SamplePerson new firstName: aString; yourself) ] @@ -52,10 +52,10 @@ MaplessUnQLiteTest >> testComposedAccess [ "Test proxies and its on-demand-load and DNU mechanism" | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -63,19 +63,19 @@ MaplessUnQLiteTest >> testComposedAccess [ repository save: guy. repository save: user. self - assert: (repository findOne: DummyUser atId: user id) completeName + assert: (repository findOne: SampleUser atId: user id) completeName equals: 'john q'. self - assert: (repository findOne: DummyUser atId: user id) person class + assert: (repository findOne: SampleUser atId: user id) person class equals: MaplessReference. self - assert: (repository findOne: DummyUser atId: user id) person model class - equals: DummyPerson. + assert: (repository findOne: SampleUser atId: user id) person model class + equals: SamplePerson. self - assert: (repository findOne: DummyUser atId: user id) person firstName + assert: (repository findOne: SampleUser atId: user id) person firstName equals: 'john'. self - assert: (repository findOne: DummyUser atId: user id) person lastName + assert: (repository findOne: SampleUser atId: user id) person lastName equals: 'q' ] @@ -87,10 +87,10 @@ MaplessUnQLiteTest >> testComposedDelete [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -115,10 +115,10 @@ MaplessUnQLiteTest >> testComposedDestroy [ do: [ :char | users add: - (DummyUser new + (SampleUser new userame: char asString; person: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself); yourself) ]. @@ -128,31 +128,31 @@ MaplessUnQLiteTest >> testComposedDestroy [ assert: (users allSatisfy: - [ :user | (repository findOne: DummyPerson atId: user person id) notNil ]). + [ :user | (repository findOne: SamplePerson atId: user person id) notNil ]). users do: [ :user | repository destroy: user person ]. self assert: (users allSatisfy: - [ :user | (repository findOne: DummyPerson atId: user person id) isNil ]). + [ :user | (repository findOne: SamplePerson atId: user person id) isNil ]). self assert: (users - allSatisfy: [ :user | (repository findOne: DummyUser atId: user id) notNil ]). + allSatisfy: [ :user | (repository findOne: SampleUser atId: user id) notNil ]). users do: [ :user | repository destroy: user ]. self assert: (users - allSatisfy: [ :user | (repository findOne: DummyUser atId: user id) isNil ]) + allSatisfy: [ :user | (repository findOne: SampleUser atId: user id) isNil ]) ] { #category : #tests } MaplessUnQLiteTest >> testComposedSave [ | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -172,11 +172,11 @@ MaplessUnQLiteTest >> testComposedSave [ MaplessUnQLiteTest >> testComposedSaveAndLoad [ | user guy loaded when | when := DateAndTime now asUTC. - user := DummyUser new + user := SampleUser new createdOn: when; username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new createdOn: when; firstName: 'john'; lastName: 'q'; @@ -191,7 +191,7 @@ MaplessUnQLiteTest >> testComposedSaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded notNil. self assert: loaded createdOn notNil. self assert: loaded modifiedOn notNil. @@ -208,24 +208,24 @@ MaplessUnQLiteTest >> testComposedSaveAndLoad [ self assert: loaded username = 'johnq'. self assert: loaded person firstName = 'john'. self assert: loaded person lastName = 'q'. - self assert: loaded person maplessClassName = #DummyPerson. - self assert: loaded person model class = DummyPerson + self assert: loaded person maplessClassName = #SamplePerson. + self assert: loaded person model class = SamplePerson ] { #category : #tests } MaplessUnQLiteTest >> testComposition [ | user guy | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. self assert: (user maplessData at: 'person') class - equals: DummyPerson. + equals: SamplePerson. self assert: user id isNil. self assert: (user maplessData at: 'person') id isNil. self assert: user completeName equals: 'john q' @@ -239,7 +239,7 @@ MaplessUnQLiteTest >> testCursorDoEach [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -248,7 +248,7 @@ MaplessUnQLiteTest >> testCursorDoEach [ cursor doEach: [ :each | self assert: each isMapless. - self assert: each class equals: DummyPerson. + self assert: each class equals: SamplePerson. found := people detect: [ :e | e id = each id ] ifNone: [ nil ]. self deny: found equals: nil. self assert: found firstName equals: each firstName ] ]. @@ -262,7 +262,7 @@ MaplessUnQLiteTest >> testCursorDoEachFollowsSortingOrder [ 1 to: 10 do: [ :index | people add: - (DummyPerson new + (SamplePerson new id: index; firstName: 'guy-' , index asString; yourself) ]. @@ -295,7 +295,7 @@ MaplessUnQLiteTest >> testDelete [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -312,7 +312,7 @@ MaplessUnQLiteTest >> testDestroy [ do: [ :char | people add: - (DummyPerson new + (SamplePerson new firstName: char asString; yourself) ]. people do: [ :guy | repository save: guy ]. @@ -320,29 +320,29 @@ MaplessUnQLiteTest >> testDestroy [ self assert: (people - allSatisfy: [ :guy | (repository findOne: DummyPerson atId: guy id) notNil ]). + allSatisfy: [ :guy | (repository findOne: SamplePerson atId: guy id) notNil ]). people do: [ :guy | repository destroy: guy ]. self assert: (people - allSatisfy: [ :guy | (repository findOne: DummyPerson atId: guy id) isNil ]) + allSatisfy: [ :guy | (repository findOne: SamplePerson atId: guy id) isNil ]) ] { #category : #tests } MaplessUnQLiteTest >> testExists [ | guy loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - self assert: (repository existsId: guy id of: DummyPerson) + self assert: (repository existsId: guy id of: SamplePerson) ] { #category : #tests } MaplessUnQLiteTest >> testIsUnsaved [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -361,35 +361,35 @@ MaplessUnQLiteTest >> testMultipleComposedComposables [ tagsOfTagsOfTags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'is this'; yourself); add: - (DummyTag new + (SampleTag new label: 'multiply'; yourself); add: - (DummyTag new + (SampleTag new label: 'composable?'; yourself); yourself. tagsOfTags add: - (DummyTag new + (SampleTag new label: 'like'; yourself); add: - (DummyTag new + (SampleTag new label: 'really?'; yourself); yourself. tagsOfTagsOfTags add: - (DummyTag new + (SampleTag new label: 'wow'; yourself); add: - (DummyTag new + (SampleTag new label: 'nice'; yourself); yourself. @@ -405,7 +405,7 @@ MaplessUnQLiteTest >> testMultipleComposedComposables [ self shouldnt: [ tags do: [ :e | repository save: e ] ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyTag atId: tags first id. + loaded := repository findOne: SampleTag atId: tags first id. self assert: loaded notNil. self assert: loaded label = 'is this'. self assert: loaded tags isCollection. @@ -424,29 +424,29 @@ MaplessUnQLiteTest >> testMultipleComposedComposables [ { #category : #tests } MaplessUnQLiteTest >> testMultipleComposedMixedSaveAndLoad [ | guy things loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. guy things: OrderedCollection new. guy things add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); add: - (DummyUser new + (SampleUser new info: 'also this'; yourself); yourself. things := guy things. guy things do: [ :each | repository save: each ]. self shouldnt: [ repository save: guy ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded notNil. self assert: loaded firstName = 'john'. self assert: loaded things isCollection. @@ -454,29 +454,29 @@ MaplessUnQLiteTest >> testMultipleComposedMixedSaveAndLoad [ loaded things do: [ :each | self assert: (things anySatisfy: [ :t | t id = each id ]) ]. loaded unreferenced. - self assert: loaded things first class = DummyTag. - self assert: loaded things second class = DummyTag. - self assert: loaded things third class = DummyUser + self assert: loaded things first class = SampleTag. + self assert: loaded things second class = SampleTag. + self assert: loaded things third class = SampleUser ] { #category : #tests } MaplessUnQLiteTest >> testMultipleComposedSaveAndLoad [ | user guy tags loaded | - user := DummyUser new + user := SampleUser new username: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. tags := OrderedCollection new. tags add: - (DummyTag new + (SampleTag new label: 'cool'; yourself); add: - (DummyTag new + (SampleTag new label: 'stuff'; yourself); yourself. @@ -489,7 +489,7 @@ MaplessUnQLiteTest >> testMultipleComposedSaveAndLoad [ self shouldnt: [ repository save: user ] raise: MaplessUnsavedSubmodel. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. self assert: loaded notNil. self assert: loaded username = 'johnq'. self assert: loaded tags isCollection. @@ -502,7 +502,7 @@ MaplessUnQLiteTest >> testMultipleComposedSaveAndLoad [ { #category : #tests } MaplessUnQLiteTest >> testSaveSetsID [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -519,7 +519,7 @@ MaplessUnQLiteTest >> testSeekGreaterThan [ 1 to: 10 do: [ :index | people add: - (DummyPerson new + (SamplePerson new id: index; firstName: 'guy-' , index asString; yourself) ]. @@ -527,7 +527,7 @@ MaplessUnQLiteTest >> testSeekGreaterThan [ repository withCursorDo: [ :cursor | | key | - key := repository namespaced: 'id' of: DummyPerson valued: 7. + key := repository namespaced: 'id' of: SamplePerson valued: 7. cursor seekGreaterThan: key. i := 7. cursor @@ -543,7 +543,7 @@ MaplessUnQLiteTest >> testSeekLessThan [ 1 to: 10 do: [ :index | people add: - (DummyPerson new + (SamplePerson new id: index; firstName: 'guy-' , index asString; yourself) ]. @@ -551,7 +551,7 @@ MaplessUnQLiteTest >> testSeekLessThan [ repository withCursorDo: [ :cursor | | key | - key := repository namespaced: 'id' of: DummyPerson valued: 7. + key := repository namespaced: 'id' of: SamplePerson valued: 7. cursor seekGreaterThan: key. i := 7. cursor @@ -563,7 +563,7 @@ MaplessUnQLiteTest >> testSeekLessThan [ { #category : #tests } MaplessUnQLiteTest >> testSimpleSave [ | guy | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. @@ -573,12 +573,12 @@ MaplessUnQLiteTest >> testSimpleSave [ { #category : #tests } MaplessUnQLiteTest >> testSimpleSaveAndLoad [ | guy loaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded notNil. loaded modifiedOn: nil. guy modifiedOn: nil. @@ -592,12 +592,12 @@ MaplessUnQLiteTest >> testSimpleSaveAndLoad [ MaplessUnQLiteTest >> testSimpleSaveAndLoadInMemory [ | guy loaded memoryRepository | memoryRepository := MaplessUnQLiteRepository inMemory. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. memoryRepository save: guy. - loaded := memoryRepository findOne: DummyPerson atId: guy id. + loaded := memoryRepository findOne: SamplePerson atId: guy id. self assert: loaded notNil. loaded modifiedOn: nil. guy modifiedOn: nil. @@ -610,37 +610,37 @@ MaplessUnQLiteTest >> testSimpleSaveAndLoadInMemory [ { #category : #tests } MaplessUnQLiteTest >> testSimpleSaveAndUpdate [ | guy loaded reloaded | - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. repository save: guy. - loaded := repository findOne: DummyPerson atId: guy id. + loaded := repository findOne: SamplePerson atId: guy id. self assert: loaded firstName = 'john'. self deny: loaded remember = 'this words'. loaded firstName: loaded firstName capitalized. loaded remember: 'this words'. repository save: loaded. - reloaded := repository findOne: DummyPerson atId: guy id. + reloaded := repository findOne: SamplePerson atId: guy id. self assert: reloaded remember = 'this words' ] { #category : #tests } MaplessUnQLiteTest >> testSubModelsFromReifiedJSON [ | user guy jsonString reified loaded | - user := DummyUser new + user := SampleUser new userame: 'johnq'; yourself. - guy := DummyPerson new + guy := SamplePerson new firstName: 'john'; lastName: 'q'; yourself. user person: guy. repository save: guy. repository save: user. - loaded := repository findOne: DummyUser atId: user id. + loaded := repository findOne: SampleUser atId: user id. jsonString := loaded unreferenced asJSONString. - reified := DummyUser fromJSONString: jsonString in: repository. - self assert: reified person class equals: DummyPerson. + reified := SampleUser fromJSONString: jsonString in: repository. + self assert: reified person class equals: SamplePerson. self assert: reified completeName equals: 'john q' ] diff --git a/src/Mapless-UnQLite-Core/MaplessUnQLiteClient.class.st b/src/Mapless-UnQLite/MaplessUnQLiteClient.class.st similarity index 98% rename from src/Mapless-UnQLite-Core/MaplessUnQLiteClient.class.st rename to src/Mapless-UnQLite/MaplessUnQLiteClient.class.st index b08a2c67..e8b3e594 100644 --- a/src/Mapless-UnQLite-Core/MaplessUnQLiteClient.class.st +++ b/src/Mapless-UnQLite/MaplessUnQLiteClient.class.st @@ -7,7 +7,7 @@ Class { #instVars : [ 'unqliteClient' ], - #category : #'Mapless-UnQLite-Core-Connections' + #category : #'Mapless-UnQLite-Connections' } { #category : #actions } diff --git a/src/Mapless-UnQLite-Core/MaplessUnQLiteCurrentClient.class.st b/src/Mapless-UnQLite/MaplessUnQLiteCurrentClient.class.st similarity index 62% rename from src/Mapless-UnQLite-Core/MaplessUnQLiteCurrentClient.class.st rename to src/Mapless-UnQLite/MaplessUnQLiteCurrentClient.class.st index 16b89872..9c7c3aab 100644 --- a/src/Mapless-UnQLite-Core/MaplessUnQLiteCurrentClient.class.st +++ b/src/Mapless-UnQLite/MaplessUnQLiteCurrentClient.class.st @@ -1,5 +1,5 @@ Class { #name : #MaplessUnQLiteCurrentClient, #superclass : #DynamicVariable, - #category : #'Mapless-UnQLite-Core-Connections' + #category : #'Mapless-UnQLite-Connections' } diff --git a/src/Mapless-UnQLite-Core/MaplessUnQLiteCursor.class.st b/src/Mapless-UnQLite/MaplessUnQLiteCursor.class.st similarity index 98% rename from src/Mapless-UnQLite-Core/MaplessUnQLiteCursor.class.st rename to src/Mapless-UnQLite/MaplessUnQLiteCursor.class.st index d8d4d6d6..17032f89 100644 --- a/src/Mapless-UnQLite-Core/MaplessUnQLiteCursor.class.st +++ b/src/Mapless-UnQLite/MaplessUnQLiteCursor.class.st @@ -5,7 +5,7 @@ Class { 'cursor', 'repository' ], - #category : #'Mapless-UnQLite-Core-Connections' + #category : #'Mapless-UnQLite-Connections' } { #category : #'instance creation' } diff --git a/src/Mapless-UnQLite-Core/MaplessUnQLitePool.class.st b/src/Mapless-UnQLite/MaplessUnQLitePool.class.st similarity index 98% rename from src/Mapless-UnQLite-Core/MaplessUnQLitePool.class.st rename to src/Mapless-UnQLite/MaplessUnQLitePool.class.st index 22a748fe..22e5e207 100644 --- a/src/Mapless-UnQLite-Core/MaplessUnQLitePool.class.st +++ b/src/Mapless-UnQLite/MaplessUnQLitePool.class.st @@ -1,3 +1,6 @@ +" +Connection pool for the Mapless repository using UnQLite +" Class { #name : #MaplessUnQLitePool, #superclass : #MaplessAbstractPool, @@ -9,7 +12,7 @@ Class { 'maxClients', 'databaseFileName' ], - #category : #'Mapless-UnQLite-Core-Connections' + #category : #'Mapless-UnQLite-Connections' } { #category : #'instance creation' } diff --git a/src/Mapless-UnQLite-Core/MaplessUnQLiteRepository.class.st b/src/Mapless-UnQLite/MaplessUnQLiteRepository.class.st similarity index 99% rename from src/Mapless-UnQLite-Core/MaplessUnQLiteRepository.class.st rename to src/Mapless-UnQLite/MaplessUnQLiteRepository.class.st index 3bda3ac0..7d6df7c5 100644 --- a/src/Mapless-UnQLite-Core/MaplessUnQLiteRepository.class.st +++ b/src/Mapless-UnQLite/MaplessUnQLiteRepository.class.st @@ -1,7 +1,7 @@ Class { #name : #MaplessUnQLiteRepository, #superclass : #MaplessRepository, - #category : #'Mapless-UnQLite-Core-Core' + #category : #'Mapless-UnQLite-Connections' } { #category : #actions } diff --git a/src/Mapless-UnQLite-Core/MaplessUnQLiteResolver.class.st b/src/Mapless-UnQLite/MaplessUnQLiteResolver.class.st similarity index 93% rename from src/Mapless-UnQLite-Core/MaplessUnQLiteResolver.class.st rename to src/Mapless-UnQLite/MaplessUnQLiteResolver.class.st index 41da641a..4c0da60a 100644 --- a/src/Mapless-UnQLite-Core/MaplessUnQLiteResolver.class.st +++ b/src/Mapless-UnQLite/MaplessUnQLiteResolver.class.st @@ -1,7 +1,7 @@ Class { #name : #MaplessUnQLiteResolver, #superclass : #MaplessResolver, - #category : #'Mapless-UnQLite-Core-Core' + #category : #'Mapless-UnQLite-Connections' } { #category : #converting } diff --git a/src/Mapless-UnQLite/package.st b/src/Mapless-UnQLite/package.st new file mode 100644 index 00000000..609bf915 --- /dev/null +++ b/src/Mapless-UnQLite/package.st @@ -0,0 +1 @@ +Package { #name : #'Mapless-UnQLite' }