Moved to JDB common build structure.
This commit is contained in:
32
libpit/src/test/com/jdbernard/pit/CategoryTest.groovy
Executable file
32
libpit/src/test/com/jdbernard/pit/CategoryTest.groovy
Executable file
@ -0,0 +1,32 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
import org.junit.Test
|
||||
import static org.junit.Assert.assertEquals
|
||||
|
||||
import static com.jdbernard.pit.Category.toCategory
|
||||
|
||||
class CategoryTest {
|
||||
|
||||
@Test void testToCategory() {
|
||||
|
||||
assertEquals toCategory("BUG"), Category.BUG
|
||||
assertEquals toCategory("FEATURE"), Category.FEATURE
|
||||
assertEquals toCategory("TASK"), Category.TASK
|
||||
|
||||
assertEquals toCategory("bug"), Category.BUG
|
||||
assertEquals toCategory("feature"), Category.FEATURE
|
||||
assertEquals toCategory("task"), Category.TASK
|
||||
|
||||
assertEquals toCategory("b"), Category.BUG
|
||||
assertEquals toCategory("f"), Category.FEATURE
|
||||
assertEquals toCategory("t"), Category.TASK
|
||||
|
||||
}
|
||||
|
||||
@Test void testGetSymbol() {
|
||||
|
||||
assertEquals Category.BUG.symbol, "b"
|
||||
assertEquals Category.FEATURE.symbol, "f"
|
||||
assertEquals Category.TASK.symbol, "t"
|
||||
}
|
||||
}
|
127
libpit/src/test/com/jdbernard/pit/FilterTest.groovy
Executable file
127
libpit/src/test/com/jdbernard/pit/FilterTest.groovy
Executable file
@ -0,0 +1,127 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.Before
|
||||
import org.junit.After
|
||||
|
||||
import static org.junit.Assert.assertTrue
|
||||
import static org.junit.Assert.assertFalse
|
||||
|
||||
class FilterTest {
|
||||
|
||||
Project proj
|
||||
|
||||
@Before void setUpIssues() {
|
||||
|
||||
proj = new MockProject('proj1')
|
||||
|
||||
def issue = new MockIssue( '0000', Category.TASK, Status.NEW, 5)
|
||||
proj.issues['0000'] = issue
|
||||
|
||||
issue = new MockIssue('0001', Category.BUG, Status.REJECTED, 3)
|
||||
proj.issues['0001'] = issue
|
||||
|
||||
issue = new MockIssue('0002', Category.BUG, Status.RESOLVED, 9)
|
||||
proj.issues['0002'] = issue
|
||||
|
||||
issue = new MockIssue('0003', Category.FEATURE, Status.REASSIGNED, 0)
|
||||
proj.issues['0003'] = issue
|
||||
|
||||
def subProj = new MockProject('subproj1')
|
||||
proj.projects['subproj1'] = subProj
|
||||
|
||||
subProj = new MockProject('subproj2')
|
||||
proj.projects['subproj2'] = subProj
|
||||
|
||||
}
|
||||
|
||||
@Test void testDefaultFilter() {
|
||||
Filter f = new Filter()
|
||||
|
||||
proj.issues.values().each { assertTrue f.accept(it) }
|
||||
proj.projects.values().each { assertTrue f.accept(it) }
|
||||
}
|
||||
|
||||
@Test void testPriorityIssueFilter() {
|
||||
Filter f = new Filter(priority: 9)
|
||||
|
||||
proj.eachIssue { assertTrue f.accept(it) }
|
||||
|
||||
f.priority = 6
|
||||
assertTrue f.accept(proj.issues['0000'])
|
||||
assertTrue f.accept(proj.issues['0001'])
|
||||
assertFalse f.accept(proj.issues['0002'])
|
||||
assertTrue f.accept(proj.issues['0003'])
|
||||
|
||||
f.priority = 5
|
||||
assertTrue f.accept(proj.issues['0000'])
|
||||
assertTrue f.accept(proj.issues['0001'])
|
||||
assertFalse f.accept(proj.issues['0002'])
|
||||
assertTrue f.accept(proj.issues['0003'])
|
||||
|
||||
f.priority = 0
|
||||
assertFalse f.accept(proj.issues['0000'])
|
||||
assertFalse f.accept(proj.issues['0001'])
|
||||
assertFalse f.accept(proj.issues['0002'])
|
||||
assertTrue f.accept(proj.issues['0003'])
|
||||
|
||||
}
|
||||
|
||||
@Test void testCategoryFilter() {
|
||||
Filter f = new Filter(categories:
|
||||
[Category.BUG, Category.FEATURE])
|
||||
|
||||
assertFalse f.accept(proj.issues['0000'])
|
||||
assertTrue f.accept(proj.issues['0001'])
|
||||
assertTrue f.accept(proj.issues['0002'])
|
||||
assertTrue f.accept(proj.issues['0003'])
|
||||
|
||||
f.categories = [ Category.TASK ]
|
||||
assertTrue f.accept(proj.issues['0000'])
|
||||
assertFalse f.accept(proj.issues['0001'])
|
||||
assertFalse f.accept(proj.issues['0002'])
|
||||
assertFalse f.accept(proj.issues['0003'])
|
||||
|
||||
f.categories = [ Category.BUG, Category.TASK ]
|
||||
assertTrue f.accept(proj.issues['0000'])
|
||||
assertTrue f.accept(proj.issues['0001'])
|
||||
assertTrue f.accept(proj.issues['0002'])
|
||||
assertFalse f.accept(proj.issues['0003'])
|
||||
|
||||
}
|
||||
|
||||
@Test void testStatusFilter() {
|
||||
Filter f = new Filter(status:
|
||||
[Status.NEW, Status.REASSIGNED, Status.REJECTED])
|
||||
|
||||
assertTrue f.accept(proj.issues['0000'])
|
||||
assertTrue f.accept(proj.issues['0001'])
|
||||
assertFalse f.accept(proj.issues['0002'])
|
||||
assertTrue f.accept(proj.issues['0003'])
|
||||
|
||||
f.status = [ Status.RESOLVED ]
|
||||
assertFalse f.accept(proj.issues['0000'])
|
||||
assertFalse f.accept(proj.issues['0001'])
|
||||
assertTrue f.accept(proj.issues['0002'])
|
||||
assertFalse f.accept(proj.issues['0003'])
|
||||
|
||||
f.status = [ Status.NEW, Status.RESOLVED ]
|
||||
assertTrue f.accept(proj.issues['0000'])
|
||||
assertFalse f.accept(proj.issues['0001'])
|
||||
assertTrue f.accept(proj.issues['0002'])
|
||||
assertFalse f.accept(proj.issues['0003'])
|
||||
}
|
||||
|
||||
@Test void testProjectFilter() {
|
||||
|
||||
}
|
||||
|
||||
@Test void testAcceptsProjectsFilter() {
|
||||
|
||||
}
|
||||
|
||||
@Test void testCompositeFilter() {
|
||||
|
||||
}
|
||||
|
||||
}
|
8
libpit/src/test/com/jdbernard/pit/MockIssue.groovy
Executable file
8
libpit/src/test/com/jdbernard/pit/MockIssue.groovy
Executable file
@ -0,0 +1,8 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
public class MockIssue extends Issue {
|
||||
public MockIssue(String id, Category c, Status s, int p) {
|
||||
super ([id: id, category: c, status: s, priority: p])
|
||||
}
|
||||
public boolean delete() { return true }
|
||||
}
|
20
libpit/src/test/com/jdbernard/pit/MockProject.groovy
Executable file
20
libpit/src/test/com/jdbernard/pit/MockProject.groovy
Executable file
@ -0,0 +1,20 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
class MockProject extends Project {
|
||||
|
||||
public MockProject(String name) { super(name) }
|
||||
|
||||
public Issue createNewIssue(Map options) {
|
||||
return new MockIssue(options.id ?: 'n/a',
|
||||
options.c ?: Category.TASK, options.s ?: Status.NEW,
|
||||
options.p ?: 5)
|
||||
}
|
||||
|
||||
public Project createNewProject(String name) {
|
||||
return new MockProject(name)
|
||||
}
|
||||
|
||||
public boolean delete() { return true }
|
||||
public boolean deleteProject(Project project) { return true }
|
||||
public boolean deleteIssue(Issue issue) { return true }
|
||||
}
|
12
libpit/src/test/com/jdbernard/pit/MockRepository.groovy
Executable file
12
libpit/src/test/com/jdbernard/pit/MockRepository.groovy
Executable file
@ -0,0 +1,12 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
class MockRepository extends Repository {
|
||||
|
||||
public void persist() {}
|
||||
|
||||
public Project[] getRootProjects() { return [] as Project[] }
|
||||
|
||||
public Project createNewProject(String name) {
|
||||
return new MockProject(name)
|
||||
}
|
||||
}
|
54
libpit/src/test/com/jdbernard/pit/StatusTest.groovy
Executable file
54
libpit/src/test/com/jdbernard/pit/StatusTest.groovy
Executable file
@ -0,0 +1,54 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
import org.junit.Test
|
||||
import static org.junit.Assert.assertEquals
|
||||
|
||||
import static com.jdbernard.pit.Status.toStatus
|
||||
|
||||
public class StatusTest {
|
||||
|
||||
@Test void testToStatus() {
|
||||
|
||||
assertEquals Status.REASSIGNED, toStatus('REASSIGNED')
|
||||
assertEquals Status.REJECTED, toStatus('REJECTED')
|
||||
assertEquals Status.NEW, toStatus('NEW')
|
||||
assertEquals Status.RESOLVED , toStatus('RESOLVED')
|
||||
assertEquals Status.VALIDATION_REQUIRED,
|
||||
toStatus('VALIDATION_REQUIRED')
|
||||
|
||||
assertEquals Status.REASSIGNED, toStatus('REA')
|
||||
assertEquals Status.REJECTED, toStatus('REJ')
|
||||
assertEquals Status.NEW, toStatus('NEW')
|
||||
assertEquals Status.RESOLVED , toStatus('RES')
|
||||
assertEquals Status.VALIDATION_REQUIRED,
|
||||
toStatus('VAL')
|
||||
|
||||
assertEquals Status.REASSIGNED, toStatus('reassigned')
|
||||
assertEquals Status.REJECTED, toStatus('rejected')
|
||||
assertEquals Status.NEW, toStatus('new')
|
||||
assertEquals Status.RESOLVED , toStatus('resolved')
|
||||
assertEquals Status.VALIDATION_REQUIRED,
|
||||
toStatus('validation_required')
|
||||
|
||||
assertEquals Status.REASSIGNED, toStatus('rea')
|
||||
assertEquals Status.REJECTED, toStatus('rej')
|
||||
assertEquals Status.NEW, toStatus('new')
|
||||
assertEquals Status.RESOLVED , toStatus('res')
|
||||
assertEquals Status.VALIDATION_REQUIRED,
|
||||
toStatus('val')
|
||||
|
||||
assertEquals Status.REASSIGNED, toStatus('A')
|
||||
assertEquals Status.REJECTED, toStatus('J')
|
||||
assertEquals Status.NEW, toStatus('N')
|
||||
assertEquals Status.RESOLVED , toStatus('S')
|
||||
assertEquals Status.VALIDATION_REQUIRED, toStatus('V')
|
||||
|
||||
assertEquals Status.REASSIGNED, toStatus('a')
|
||||
assertEquals Status.REJECTED, toStatus('j')
|
||||
assertEquals Status.NEW, toStatus('n')
|
||||
assertEquals Status.RESOLVED , toStatus('s')
|
||||
assertEquals Status.VALIDATION_REQUIRED, toStatus('v')
|
||||
|
||||
}
|
||||
|
||||
}
|
228
libpit/src/test/com/jdbernard/pit/file/FileIssueTest.groovy
Executable file
228
libpit/src/test/com/jdbernard/pit/file/FileIssueTest.groovy
Executable file
@ -0,0 +1,228 @@
|
||||
package com.jdbernard.pit.file
|
||||
|
||||
import com.jdbernard.pit.*
|
||||
import org.junit.*
|
||||
import static org.junit.Assert.assertTrue
|
||||
import static org.junit.Assert.assertFalse
|
||||
import static org.junit.Assert.assertEquals
|
||||
|
||||
class FileIssueTest {
|
||||
|
||||
def issues
|
||||
File testDir
|
||||
|
||||
@Before void makeIssueFiles() {
|
||||
File issueFile
|
||||
issues = []
|
||||
|
||||
testDir = new File('testdir')
|
||||
testDir.mkdirs()
|
||||
|
||||
issueFile = new File(testDir, '0001fn1.rst')
|
||||
issueFile.write(
|
||||
"Add the killer feature to the killer app.\n" +
|
||||
"=========================================\n\n" +
|
||||
"Make our killer app shine!.")
|
||||
issues << new FileIssue(issueFile)
|
||||
|
||||
issueFile = new File(testDir, '0002ts5.rst')
|
||||
issueFile.write(
|
||||
"Obtain donuts.\n" +
|
||||
"==============\n\n" +
|
||||
"The office is seriously lacking in sugary donuts.\n\n" +
|
||||
"We must rectify this at once!")
|
||||
issues << new FileIssue(issueFile)
|
||||
}
|
||||
|
||||
@After void deleteIssueFiles() {
|
||||
assert testDir.deleteDir()
|
||||
}
|
||||
|
||||
@Test void testSetCategory() {
|
||||
|
||||
assertEquals issues[0].category, Category.FEATURE
|
||||
assertEquals issues[1].category, Category.TASK
|
||||
|
||||
try {
|
||||
issues[0].category = Category.TASK
|
||||
issues[1].category = Category.BUG
|
||||
} catch (Exception e) {
|
||||
Assert.fail("An unexpected Exception occurred: "
|
||||
+ e.getLocalizedMessage())
|
||||
}
|
||||
|
||||
assertEquals issues[0].category, Category.TASK
|
||||
assertEquals issues[1].category, Category.BUG
|
||||
|
||||
assertTrue new File(testDir, '0001tn1.rst').exists()
|
||||
assertTrue new File(testDir, '0002bs5.rst').exists()
|
||||
assertFalse new File(testDir, '0001fn1.rst').exists()
|
||||
assertFalse new File(testDir, '0002ts5.rst').exists()
|
||||
|
||||
}
|
||||
|
||||
@Test void testSetCategoryFails() {
|
||||
FileInputStream fin
|
||||
try {
|
||||
// get a lock to the file to prevent the rename
|
||||
def issueFile = new File('0001fn1.rst')
|
||||
fin = new FileInputStream(issueFile)
|
||||
|
||||
// try to set the category
|
||||
issues[0].category = Category.TASK
|
||||
|
||||
// should throw IOE before here
|
||||
Assert.fail()
|
||||
} catch (IOException ioe) {
|
||||
} catch (Exception e) {
|
||||
Assert.fail("Unexpected exception: " + e.getLocalizedMessage())
|
||||
} finally {
|
||||
if (fin != null) fin.close()
|
||||
}
|
||||
}
|
||||
|
||||
@Test void testSetStatus() {
|
||||
|
||||
assertEquals issues[0].status, Status.NEW
|
||||
assertEquals issues[1].status, Status.RESOLVED
|
||||
|
||||
try {
|
||||
issues[0].status = Status.RESOLVED
|
||||
issues[1].status = Status.REJECTED
|
||||
} catch (Exception e) {
|
||||
Assert.fail("An unexpected Exception occurred: "
|
||||
+ e.getLocalizedMessage())
|
||||
}
|
||||
|
||||
assertTrue new File(testDir, '0001fs1.rst').exists()
|
||||
assertTrue new File(testDir, '0002tj5.rst').exists()
|
||||
assertFalse new File(testDir, '0001fn1.rst').exists()
|
||||
assertFalse new File(testDir, '0002ts5.rst').exists()
|
||||
}
|
||||
|
||||
@Test void testSetStatusFails() {
|
||||
FileInputStream fin
|
||||
try {
|
||||
// get a lock to the file to prevent the rename
|
||||
def issueFile = new File('0001fn1.rst')
|
||||
fin = new FileInputStream(issueFile)
|
||||
|
||||
// try to set the status
|
||||
issues[0].status = Status.REJECTED
|
||||
|
||||
// should throw IOE before here
|
||||
Assert.fail()
|
||||
} catch (IOException ioe) {
|
||||
} catch (Exception e) {
|
||||
Assert.fail("Unexpected exception: " + e.getLocalizedMessage())
|
||||
} finally {
|
||||
if (fin != null) fin.close()
|
||||
}
|
||||
}
|
||||
|
||||
@Test void testSetPriority() {
|
||||
|
||||
assertEquals issues[0].priority, 1
|
||||
assertEquals issues[1].priority, 5
|
||||
|
||||
try {
|
||||
issues[0].priority = 2
|
||||
issues[1].priority = 9
|
||||
} catch (Exception e) {
|
||||
Assert.fail("An unexpected Exception occurred: "
|
||||
+ e.getLocalizedMessage())
|
||||
}
|
||||
|
||||
assertEquals issues[0].priority, 2
|
||||
assertEquals issues[1].priority, 9
|
||||
|
||||
assertTrue new File(testDir, '0001fn2.rst').exists()
|
||||
assertTrue new File(testDir, '0002ts9.rst').exists()
|
||||
assertFalse new File(testDir, '0001fn1.rst').exists()
|
||||
assertFalse new File(testDir, '0002ts5.rst').exists()
|
||||
}
|
||||
|
||||
@Test void testSetPriorityFails() {
|
||||
FileInputStream fin
|
||||
try {
|
||||
// get a lock to the file to prevent the rename
|
||||
def issueFile = new File('0001fn1.rst')
|
||||
fin = new FileInputStream(issueFile)
|
||||
|
||||
// try to set the priority
|
||||
issues[0].priority = 9
|
||||
|
||||
// should throw IOE before here
|
||||
Assert.fail()
|
||||
} catch (IOException ioe) {
|
||||
} catch (Exception e) {
|
||||
Assert.fail("Unexpected exception: " + e.getLocalizedMessage())
|
||||
} finally {
|
||||
if (fin != null) fin.close()
|
||||
}
|
||||
}
|
||||
|
||||
@Test void testConstruction() {
|
||||
File issueFile = new File(testDir, '0001fn1.rst')
|
||||
Issue issue = new FileIssue(issueFile)
|
||||
|
||||
assertEquals issue.id , "0001"
|
||||
assertEquals issue.category , Category.FEATURE
|
||||
assertEquals issue.status , Status.NEW
|
||||
assertEquals issue.priority , 1
|
||||
assertEquals issue.title , "Add the killer feature to the killer app."
|
||||
assertEquals issue.text , "Make our killer app shine!."
|
||||
assertEquals issue.source , issueFile
|
||||
}
|
||||
|
||||
@Test void testSetTextFails() {
|
||||
try {
|
||||
// make the issue file un-writable
|
||||
def issueFile = new File('0001fn1.rst')
|
||||
if (issueFile.setReadOnly()) {
|
||||
|
||||
// try to write something
|
||||
issues[0].text = "This should fail to be written."
|
||||
|
||||
// should throw IOE before here
|
||||
Assert.fail()
|
||||
} else {
|
||||
println "Could not run testSetTextFails, unable to change " +
|
||||
"the test isseu file's permissions."
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
} catch (Exception e) {
|
||||
Assert.fail("Unexpected exception: " + e.getLocalizedMessage())
|
||||
}
|
||||
}
|
||||
|
||||
@Test void testMakeFilename() {
|
||||
assertEquals FileIssue.makeFilename('0001', Category.BUG,
|
||||
Status.NEW, 5), '0001bn5.rst'
|
||||
assertEquals FileIssue.makeFilename('0010', Category.FEATURE,
|
||||
Status.REASSIGNED, 1), '0010fa1.rst'
|
||||
assertEquals FileIssue.makeFilename('0002', Category.FEATURE,
|
||||
Status.REJECTED, 3), '0002fj3.rst'
|
||||
assertEquals FileIssue.makeFilename('0001', Category.BUG,
|
||||
Status.RESOLVED, -2), '0001bs0.rst'
|
||||
assertEquals FileIssue.makeFilename('0001', Category.TASK,
|
||||
Status.VALIDATION_REQUIRED, 10) , '0001tv9.rst'
|
||||
assertEquals FileIssue.makeFilename('00101', Category.BUG,
|
||||
Status.NEW, 5), '00101bn5.rst'
|
||||
|
||||
try {
|
||||
FileIssue.makeFilename('badid', Category.BUG, Status.NEW, 5)
|
||||
assertTrue 'Issue.makeFilename() succeeded with bad id input.', false
|
||||
} catch (IllegalArgumentException iae) {}
|
||||
|
||||
try {
|
||||
FileIssue.makeFilename('0002', null, Status.NEW, 5)
|
||||
assertTrue 'Issue.makeFilename() succeeded given no Category.', false
|
||||
} catch (IllegalArgumentException iae) {}
|
||||
|
||||
try {
|
||||
FileIssue.makeFilename('0002', Category.BUG, null, 5)
|
||||
assertTrue 'Issue.makeFilename() succeeded given no Status.', false
|
||||
} catch (IllegalArgumentException iae) {}
|
||||
}
|
||||
}
|
162
libpit/src/test/com/jdbernard/pit/file/FileProjectTest.groovy
Executable file
162
libpit/src/test/com/jdbernard/pit/file/FileProjectTest.groovy
Executable file
@ -0,0 +1,162 @@
|
||||
package com.jdbernard.pit.file
|
||||
|
||||
import com.jdbernard.pit.*
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertFalse
|
||||
import static org.junit.Assert.assertNotNull
|
||||
import static org.junit.Assert.assertTrue
|
||||
|
||||
class FileProjectTest {
|
||||
|
||||
File testDir
|
||||
Project rootProj
|
||||
|
||||
@Before void createTestProjects() {
|
||||
|
||||
testDir = new File('testdir')
|
||||
assert !testDir.exists()
|
||||
testDir.mkdirs()
|
||||
|
||||
/* TEST SUITE:
|
||||
/testdir/
|
||||
0001t5.rst
|
||||
0002b5.rst
|
||||
0003f2.rst
|
||||
|
||||
subproj1/
|
||||
0001f3.rst
|
||||
0002b4.rst
|
||||
|
||||
emptyproj/
|
||||
|
||||
*/
|
||||
|
||||
def issueFile = new File(testDir, '0001tn5.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('Test Issue 1\n' +
|
||||
'============\n\n' +
|
||||
'This is the first test issue.')
|
||||
|
||||
issueFile = new File(testDir, '0002ba5.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('Test Bug\n' +
|
||||
'========\n\n' +
|
||||
'Yeah, it is a test bug.')
|
||||
|
||||
issueFile = new File(testDir, '0003fs2.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('Important Feature Request\n' +
|
||||
'=========================\n\n' +
|
||||
'Here is our sweet feature. Please implement it!')
|
||||
|
||||
def subDir = new File(testDir, 'subproj1')
|
||||
subDir.mkdirs()
|
||||
|
||||
issueFile = new File(subDir, '0001fv3.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('First feature in subproject\n' +
|
||||
'===========================\n\n' +
|
||||
'Please make the grubblers grobble.')
|
||||
|
||||
issueFile = new File(subDir, '0002bj4.rst')
|
||||
issueFile.createNewFile()
|
||||
issueFile.write('Zippners are not zippning.\n' +
|
||||
'==========================\n\n' +
|
||||
'For some reason, the Zippners are bilperring, not zippning.')
|
||||
|
||||
subDir = new File(testDir, 'emptyproj')
|
||||
subDir.mkdirs()
|
||||
|
||||
rootProj = new FileProject(testDir)
|
||||
}
|
||||
|
||||
@After void deleteTestProjects() {
|
||||
assert testDir.deleteDir()
|
||||
|
||||
if (rootProj.source.exists())
|
||||
assert rootProj.source.deleteDir()
|
||||
}
|
||||
|
||||
@Test void testConstruction() {
|
||||
Project proj = new FileProject(testDir)
|
||||
|
||||
assertEquals proj.name, 'testdir'
|
||||
assertEquals proj.issues.size(), 3
|
||||
assertEquals proj.projects.size(), 2
|
||||
|
||||
// Issue construction in general is under test in IssueTest
|
||||
// just check that the issues actually exists
|
||||
assertEquals proj.issues['0001'].id, '0001'
|
||||
assertEquals proj.issues['0001'].title, 'Test Issue 1'
|
||||
|
||||
assertEquals proj.issues['0002'].id, '0002'
|
||||
assertEquals proj.issues['0002'].title, 'Test Bug'
|
||||
|
||||
assertEquals proj.issues['0003'].id, '0003'
|
||||
assertEquals proj.issues['0003'].title, 'Important Feature Request'
|
||||
|
||||
// check sub-project behaviour
|
||||
assertNotNull proj.projects.subproj1
|
||||
assertEquals proj.projects.subproj1.name, 'subproj1'
|
||||
assertEquals proj.projects.subproj1.issues.size(), 2
|
||||
assertEquals proj.projects.subproj1.projects.size(), 0
|
||||
assertEquals proj.projects.subproj1.issues['0001'].id, '0001'
|
||||
assertEquals proj.projects.subproj1.issues['0002'].id, '0002'
|
||||
assertEquals proj.projects.subproj1.issues['0001'].title,
|
||||
'First feature in subproject'
|
||||
assertEquals proj.projects.subproj1.issues['0002'].title,
|
||||
'Zippners are not zippning.'
|
||||
|
||||
assertNotNull proj.projects.emptyproj
|
||||
assertEquals proj.projects.emptyproj.issues.size(), 0
|
||||
assertEquals proj.projects.emptyproj.projects.size(), 0
|
||||
}
|
||||
|
||||
@Test void testRename() {
|
||||
assert rootProj.name == 'testdir'
|
||||
|
||||
rootProj.name = 'renamedTestDir'
|
||||
|
||||
assertEquals rootProj.name, 'renamedTestDir'
|
||||
assertTrue new File('renamedTestDir').exists()
|
||||
|
||||
assert rootProj.source.deleteDir()
|
||||
}
|
||||
|
||||
@Test void testCreateNewIssue() {
|
||||
|
||||
// test correct increment of id, application of values
|
||||
def newIssue = rootProj.createNewIssue(category: Category.BUG,
|
||||
status: Status.REASSIGNED, priority: 4,
|
||||
text: 'A newly made bug report.\n'+
|
||||
'========================\n\n' +
|
||||
'Testing the Project.createNewIssue() method.')
|
||||
|
||||
assertEquals newIssue.id, '0004'
|
||||
assertEquals newIssue.category, Category.BUG
|
||||
assertEquals newIssue.status, Status.REASSIGNED
|
||||
assertEquals newIssue.priority, 4
|
||||
assertEquals newIssue.text, 'A newly made bug report.\n'+
|
||||
'========================\n\n' +
|
||||
'Testing the Project.createNewIssue() method.'
|
||||
assertEquals rootProj.issues[(newIssue.id)], newIssue
|
||||
|
||||
//test defaults and creation of issue in an empty project
|
||||
newIssue = rootProj.projects.emptyproj.createNewIssue()
|
||||
|
||||
assertEquals newIssue.id, '0000'
|
||||
assertEquals newIssue.priority, 5
|
||||
assertEquals newIssue.category, Category.TASK
|
||||
assertEquals newIssue.status, Status.NEW
|
||||
assertEquals newIssue.text, 'Default issue title.\n' +
|
||||
'====================\n'
|
||||
|
||||
assertEquals rootProj.projects.emptyproj.issues[(newIssue.id)],
|
||||
newIssue
|
||||
|
||||
}
|
||||
|
||||
}
|
27
libpit/src/test/com/jdbernard/pit/xml/XmlIssueTest.groovy
Executable file
27
libpit/src/test/com/jdbernard/pit/xml/XmlIssueTest.groovy
Executable file
@ -0,0 +1,27 @@
|
||||
package com.jdbernard.pit.xml
|
||||
|
||||
import com.jdbernard.pit.*
|
||||
import groovy.util.Node
|
||||
import org.junit.Test
|
||||
import static org.junit.Assert.assertEquals
|
||||
import static org.junit.Assert.assertFalse
|
||||
import static org.junit.Assert.assertTrue
|
||||
|
||||
public class XmlIssueTest {
|
||||
|
||||
Node issueNode = new Node(null, 'Issue',
|
||||
[id: '0000', category: 'BUG', status: 'RESOLVED', priority: 1],
|
||||
'Test Issue')
|
||||
|
||||
@Test public void testDummyTest() {}
|
||||
|
||||
/*@Test public void testNodeConstructor() {
|
||||
XmlIssue issue = new XmlIssue(issueNode)
|
||||
|
||||
assertEquals issue.text, 'Test Issue'
|
||||
assertEquals issue.id, '0000'
|
||||
assertEquals issue.category, Category.BUG
|
||||
assertEquals issue.status, Status.RESOLVED
|
||||
assertEquals issue.priority, 1
|
||||
}*/
|
||||
}
|
Reference in New Issue
Block a user