Skip to content

Commit

Permalink
test: ClosedTicketsMetricTest
Browse files Browse the repository at this point in the history
  • Loading branch information
BAUVENT Kilian committed Sep 5, 2024
1 parent 3dddb4e commit 8f78d52
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"
A ClosedTicketsMetricTest is a test class for testing the behavior of ClosedTicketsMetric
"
Class {
#name : #ClosedTicketsMetricTest,
#superclass : #TestCase,
#category : #'GitLabHealth-Model-Analysis-Tests'
}

{ #category : #tests }
ClosedTicketsMetricTest >> testCalculate [

| result glhImporter user closedTicket jiraImporter |
"Given"
user := GLHUser new
username: 'test';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.

glhImporter := GLPHImporterMock new.
glhImporter mergeRequests: { (GLPHEMergeRequest new
author: user;
created_at: '09-05-2024';
title: '205 feat do something') }.

jiraImporter := JiraImporterMock new.
jiraImporter issues: { (JPIssue new key: '205') }.


closedTicket := ClosedTicketsMetric new
user: user;
glhImporter: glhImporter;
jiraImporter: jiraImporter;
setPeriodSince: '09-04-2024' until: '09-04-2024';
over: Week.

"When"
result := closedTicket calculate.

"Then"
self assert: result equals: 1
]
25 changes: 21 additions & 4 deletions src/GitLabHealth-Model-Analysis-Tests/GLPHImporterMock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Class {
#instVars : [
'commits',
'commitDiffs',
'mergeRequests'
'mergeRequests',
'glhModel'
],
#category : #'GitLabHealth-Model-Analysis-Tests'
}
Expand Down Expand Up @@ -32,10 +33,23 @@ GLPHImporterMock >> completeImportedCommit: commit [
^self
]

{ #category : #accessing }
GLPHImporterMock >> glhModel [

^ glhModel
]

{ #category : #accessing }
GLPHImporterMock >> glhModel: anObject [

glhModel := anObject
]

{ #category : #commit }
GLPHImporterMock >> importCommitsOProject: project since: since until: until [

^commits
glhModel addAll: commits.
^ commits
]

{ #category : #'as yet unclassified' }
Expand All @@ -46,8 +60,9 @@ GLPHImporterMock >> importCreatorOfCommit: commit [

{ #category : #'import - merge request' }
GLPHImporterMock >> importMergeRequests: project since: since until: until [
^mergeRequests


glhModel addAll: mergeRequests.
^ mergeRequests
]

{ #category : #'import - merge request' }
Expand All @@ -65,6 +80,8 @@ GLPHImporterMock >> initialize [

commits := OrderedCollection new.
mergeRequests := OrderedCollection new.

glhModel := GLPHEModel new name: 'model'
]

{ #category : #accessing }
Expand Down
45 changes: 45 additions & 0 deletions src/GitLabHealth-Model-Analysis-Tests/JiraImporterMock.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Class {
#name : #JiraImporterMock,
#superclass : #Object,
#instVars : [
'issues',
'model'
],
#category : #'GitLabHealth-Model-Analysis-Tests'
}

{ #category : #'api - import' }
JiraImporterMock >> importAllCurrentAndPastIssuesOf: email [

model addAll: issues.
^ issues
]

{ #category : #initialization }
JiraImporterMock >> initialize [
model := GLPHEModel new name: 'model'
]

{ #category : #accessing }
JiraImporterMock >> issues [

^ issues
]

{ #category : #accessing }
JiraImporterMock >> issues: anObject [

issues := anObject
]

{ #category : #accessing }
JiraImporterMock >> model [

^ model
]

{ #category : #accessing }
JiraImporterMock >> model: anObject [

model := anObject
]
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ GLHUserCatalogueV2 >> exportToJson [
(#id -> assoc key id) } asDictionary); yourself ]."
tempDic := Dictionary new.
self associationsDo: [ :assoc |
|entry user names|
| entry user names |
entry := assoc value.
user := entry at: #user.
names := entry at: #names.
Expand Down
1 change: 0 additions & 1 deletion src/GitProject-JiraConnector/GPJCConnector.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Class {

{ #category : #accessing }
GPJCConnector >> connect [

(self gpModel allWithType: GLHCommit) do: [ :commit |
self connectCommit: commit ].
(self gpModel allWithType: GLPHEMergeRequest) do: [ :mergeRequest |
Expand Down

0 comments on commit 8f78d52

Please sign in to comment.