Skip to content

Commit

Permalink
integrated testMoveTo, fix testRead, chg ICSetUpTestHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
Alorcus committed Jul 8, 2022
1 parent d6b6a64 commit 68ad176
Show file tree
Hide file tree
Showing 43 changed files with 163 additions and 91 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
converting
transferAttributesFrom: anICEmail

self id: anICEmail id;
body: anICEmail body;
header: anICEmail header;
folder: anICEmail folder;
messageID: anICEmail messageID;
uniqueID: anICEmail uniqueID

Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"subject:" : "C.G. 7/25/2018 13:49",
"to" : "hg 7/30/2020 11:25",
"to:" : "C.G. 7/25/2018 13:49",
"transferAttributesFrom:" : "RJPG 7/8/2022 13:27",
"uniqueID" : "pm 6/2/2019 15:58",
"uniqueID:" : "pm 6/2/2019 15:58" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
collectAllFolders

^ self rootFolder collectAllFolders
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
unlinkAllEmails

^ self rootFolder unlink
^ self rootFolder unlinkAllEmails
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"addMail:to:" : "an 6/16/2022 20:29",
"close" : "JST 6/6/2021 23:35",
"collectAllEmails" : "Hannes Spitz4 7/5/2022 16:39",
"collectAllFolders" : "RJPG 7/8/2022 11:11",
"connect" : "sf 6/4/2021 13:57",
"connectAndLogin" : "an 6/16/2022 20:29",
"connectionHandler" : "JST 6/5/2021 20:25",
Expand Down Expand Up @@ -81,6 +82,6 @@
"sendNextCommands" : "an 6/16/2022 20:29",
"setFolderNamePath:" : "an 6/16/2022 20:29",
"switchFlag:for:to:" : "an 6/16/2022 20:29",
"unlinkAllEmails" : "RJPG 7/7/2022 12:04",
"unlinkAllEmails" : "RJPG 7/8/2022 12:16",
"updateFlagsFor:with:" : "an 6/16/2022 20:29",
"updateFolderType:with:" : "an 6/16/2022 20:29" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ addMailTo: aFolder from: aFile
yourself.
matchingEmail:= self loadedEmails select: [:e | e id = email id].

self halt.
matchingEmail isEmpty
ifTrue: [aFolder addMails: {email}]
ifFalse: [
self assert: matchingEmail size = 1 description: 'Crutical Error. Email ID is not Unique!'.
matchingEmail first deserializeFrom: (Json readFrom: aFile).
matchingEmail first folder: email folder.
matchingEmail first transferAttributesFrom: email.

aFolder addMails: {matchingEmail first}]

Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
read file
directoryVisitor

^ [:directory | | currentFolder |

^ [:directory | | currentFolder folderName matchingFolder |
self directoryToFolderDictionary at: directory ifAbsent:[
directory = self rootDirectory ifFalse: [
currentFolder := ICFolder
folderName :=directory pathParts last.
matchingFolder:= self loadedFolders select: [:f | f folderName = folderName].

matchingFolder isEmpty
ifTrue: [currentFolder := ICFolder
named: directory pathParts last
in: (self directoryToFolderDictionary at: directory containingDirectory)
with: self endpoint
of: #Generic.
of: #Generic.]
ifFalse: [
self assert: matchingFolder size = 1 description: 'Crutical Error. FolderName is not Unique! You should change the name to id ;)'.
currentFolder:= matchingFolder first].
self directoryToFolderDictionary at: directory put: currentFolder]]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
loadedFolders: anOrderdCollection

loadedFolders := anOrderdCollection
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
loadedFolders
^ loadedFolders
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ read file
syncFromDisk

self loadedEmails: self endpoint collectAllEmails.
"self endpoint unlinkAllEmails."
self loadedFolders: self endpoint collectAllFolders.
self endpoint unlinkAllEmails.
self readEmailsFromDisk.
" self loadedEmails: OrderedCollection new."
self loadedEmails: OrderedCollection new.
self loadedFolders: OrderedCollection new.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
"class" : {
"newWith:" : "an 6/16/2022 20:29" },
"instance" : {
"addMailTo:from:" : "Hannes Spitz4 7/7/2022 19:52",
"addMailTo:from:" : "RJPG 7/8/2022 12:03",
"delete:" : "RJPG 6/21/2022 11:00",
"directoryToFolderDictionary" : "an 6/16/2022 20:29",
"directoryVisitor" : "Hannes Spitz4 7/7/2022 19:32",
"directoryVisitor" : "RJPG 7/8/2022 11:48",
"endpoint" : "an 6/16/2022 20:29",
"endpoint:" : "an 6/16/2022 20:29",
"fileVisitor" : "an 6/16/2022 20:29",
"isICFolderFile:" : "RJPG 5/30/2022 20:06",
"loadedEmails" : "RJPG 7/7/2022 12:08",
"loadedEmails:" : "RJPG 7/7/2022 12:08",
"loadedFolders" : "RJPG 7/8/2022 11:11",
"loadedFolders:" : "RJPG 7/8/2022 11:11",
"moveEmail:to:" : "RJPG 7/7/2022 15:52",
"readEmailsFromDisk" : "RJPG 7/7/2022 12:06",
"rootDirectory" : "an 6/16/2022 20:29",
"syncFromDisk" : "RJPG 7/7/2022 12:20",
"syncFromDisk" : "RJPG 7/8/2022 13:24",
"write:" : "an 6/16/2022 20:29",
"write:in:" : "RJPG 6/21/2022 10:37",
"writeFolder:" : "an 6/16/2022 20:29" } }
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"instvars" : [
"directoryToFolderDictionary",
"endpoint",
"loadedEmails" ],
"loadedEmails",
"loadedFolders" ],
"name" : "ICFileReadWriter",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
accessing
collectAllFolders

|allFolders |

allFolders:= OrderedCollection new.
allFolders addAll: {self}.
self childFolders do:[:folder|
allFolders addAll: folder collectAllFolders].

^ allFolders
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"childFolders" : "FK 5/16/2022 18:27",
"childFoldersSorted" : "an 6/16/2022 20:27",
"collectAllEmails" : "Hannes Spitz4 7/5/2022 16:41",
"collectAllFolders" : "RJPG 7/8/2022 11:16",
"countFolders" : "an 6/16/2022 20:29",
"emails" : "LW 7/31/2020 12:27",
"emails:" : "LW 7/31/2020 12:26",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
helper: anICSetUpTestHelper

helper := anICSetUpTestHelper
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
helper
^ helper
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ running
setUp

| connectionHandler folder |

self helper: ICSetUpTestHelper new.

connectionHandler := ICConnectionHandler new
stream: ICNullStream new;
storedCommands: ICMockCommandStorage new.
Expand All @@ -15,4 +18,5 @@ setUp
folderNameOfTrash: self trashFolderName;
readWriter: ICMockReadWriter new.

self helper endpoint: self endPoint.
self email: (self class mailIn: folder)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
constants
testUnlinkAllEmails

| folder mail |

folder:= self helper createAFolder: 'folder'.

mail := self helper createAnEmail: folder.
self assert: (folder emails contains: [:e| e = mail]).
self helper endpoint unlinkAllEmails.

self assert: folder emails isEmpty
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"endPoint" : "an 6/16/2022 20:29",
"endPoint:" : "an 6/16/2022 20:29",
"folder" : "eg 7/29/2021 18:05",
"setUp" : "an 6/16/2022 20:29",
"helper" : "RJPG 7/8/2022 12:10",
"helper:" : "RJPG 7/8/2022 12:11",
"setUp" : "RJPG 7/8/2022 12:14",
"tearDown" : "an 6/16/2022 20:29",
"testDeleteEmailOffline" : "an 6/16/2022 20:29",
"testDeleteEmailOnline" : "an 6/16/2022 20:29",
Expand All @@ -17,5 +19,6 @@
"testMoveEmailOffline" : "an 6/16/2022 20:29",
"testSwitchFlagOffline" : "an 6/16/2022 20:29",
"testSwitchFlagOnline" : "eg 7/29/2021 18:08",
"testUnlinkAllEmails" : "RJPG 7/8/2022 12:14",
"trashFolder" : "FK 6/2/2022 13:29",
"trashFolderName" : "eg 7/29/2021 18:31" } }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"commentStamp" : "eg 7/29/2021 18:37",
"instvars" : [
"endPoint",
"email" ],
"email",
"helper" ],
"name" : "ICEndPointOfflineTest",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ teardown
tearDown

(FileDirectory default / self endpoint maildirFileName) deleteLocalFiles.
self helper tearDown.
self helper reset.
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
delteFile
testDelete

self createFileWith: self deleteUID.
self assert: (FileDirectory default / (self endpoint maildirFileName: self endpoint rootFolder folderName) / self deleteUID asString) exists.
self readWriter delete: (self class expectedMailObjectFor: self deleteUID in: self endpoint rootFolder).
self assert: (FileDirectory default / self endpoint maildirFileName / self deleteUID asString) exists not
| folder mail |
"self createFileWith: self deleteUID."
folder := self helper createAFolder: 'folder'.
mail := self helper createAnEmail: folder.

self assert: (FileDirectory default / (self endpoint maildirFileName: self helper endpoint rootFolder folderName) / mail uniqueID asString) exists.


"self readWriter delete: (self class expectedMailObjectFor: self deleteUID in: self endpoint rootFolder).
self assert: (FileDirectory default / self endpoint maildirFileName / self deleteUID asString) exists not"
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ testMoveTo

| mail moveToFolder originFolder |

moveToFolder:= self helper createAnFolder: 'moveToFolder'.
originFolder := self helper createAnFolder: 'originFolder'.
self readWriter: (ICFileReadWriter new endpoint: self helper endpoint)."remove this, should be in SetUP!"
moveToFolder:= self helper createAFolder: 'moveToFolder'.
originFolder := self helper createAFolder: 'originFolder'.

mail := self helper createAnEmail: originFolder.
"mail:= self createFileWith: self moveToUID."
self assert: mail folder equals: originFolder.
self assert: (originFolder emails contains: [:e| e = mail]).
self halt.
self readWriter moveEmail: mail to: moveToFolder.

self assert: originFolder emails isEmpty.
self assert: mail folder equals: moveToFolder.
self assert: (moveToFolder emails contains: mail)
self assert: (moveToFolder emails contains: [:e| e = mail])
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
UIDs
testRead

self createFileWith: self readUID.
self readWriter readEmailsFromDisk.
self
assert: {self class expectedMailObjectFor: self readUID in: self endpoint rootFolder}
equals: self endpoint rootFolder emails asArray
| folder mail |

self readWriter: (ICFileReadWriter new endpoint: self helper endpoint)."remove this, should be in SetUP!"
folder := self helper createAFolder: 'folder'.
mail := self helper createAnEmail: folder.
folder emails: OrderedCollection new.

self readWriter syncFromDisk.
self assert: (folder emails contains: [:e | e id = mail id ]).
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"readWriter" : "dl 7/20/2017 10:54",
"readWriter:" : "pm 6/9/2019 17:18",
"setUp" : "RJPG 7/8/2022 00:09",
"tearDown" : "RJPG 7/8/2022 00:14",
"testDelete" : "Hannes Spitz4 6/21/2022 12:25",
"testMoveTo" : "RJPG 7/8/2022 00:55",
"testRead" : "RJPG 6/21/2022 10:22",
"tearDown" : "RJPG 7/8/2022 09:20",
"testDelete" : "RJPG 7/8/2022 12:27",
"testMoveTo" : "RJPG 7/8/2022 12:24",
"testRead" : "RJPG 7/8/2022 12:24",
"testWrite" : "RJPG 6/21/2022 10:22",
"writeUID" : "hg 7/31/2020 11:29" } }
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"mailBody" : "C.G. 7/25/2018 18:10",
"mailBody:" : "pm 6/9/2019 17:19",
"maildirDiffFetchHeadersFor:from:" : "an 6/16/2022 20:29",
"maildirFileName" : "an 6/16/2022 20:29",
"maildirFileName" : "RJPG 7/8/2022 13:26",
"readWriter" : "JNG 5/24/2021 10:40",
"retrieveBody:" : "JNG 5/24/2021 10:43",
"retrieveFlagsFrom:to:in:" : "an 6/16/2022 20:29",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
An ICSetUpTestHelper is an extension for the unit tests. Its purpose is to help create clean and consistent setUps.
The class creates a clean endpoint. It also provides methods for creating folders and emails. Each object is written to disk. The SetUpTestHelper ensure an empty TestEnvironment.
To be independet from the FileReadWriter, the class has its own IO-operations.

Instance Variables
currentMailID: <Number>
endpoint: <ICEndPont>

currentMailID
- A Number which gets increased with each call. Needed for unique email uids.

Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ getMailObjectWith: UID in: anICFolder
contentTransferEncoding: 'quoted-printable';
to: {'receiver1'. 'receiver2'};
date: 'Fri, 10 Jun 2016 12:51:42 +0200';
uniqueID: UID
uniqueID: UID;
messageID: UID
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
createAFolder: anName

^ self createAFolder: anName in: self endpoint rootFolder
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
accessing
createAnFolder: anName in: anICParentFolder
createAFolder: anName in: anICParentFolder

| folder |
folder := ICFolder named: anName in: anICParentFolder with: self endpoint of: #Generic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ createAnEmail: anICFolder

| mail |
mail := self class getMailObjectWith: (self currentMailID) in: anICFolder.
mail folder: anICFolder.
anICFolder addMails: {mail}.
self writeEmailOnDisk: mail.

Expand Down

This file was deleted.

Loading

0 comments on commit 68ad176

Please sign in to comment.