summaryrefslogtreecommitdiffstats
path: root/idrop-web
diff options
context:
space:
mode:
authorMike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-02-16 21:21:03 (GMT)
committer Mike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-02-16 21:21:03 (GMT)
commitd9704159770f7393245bc8020aa7386747255df1 (patch)
tree1ecd5f5fa6ce461ca8be20a49b38ad44138ecbbf /idrop-web
parentc6e9138951e5ceb56b4e0e0194900c8cfd1a6e84 (diff)
downloadQCG-Data-d9704159770f7393245bc8020aa7386747255df1.zip
QCG-Data-d9704159770f7393245bc8020aa7386747255df1.tar.gz
QCG-Data-d9704159770f7393245bc8020aa7386747255df1.tar.bz2
fix tests for browsecontroller
Diffstat (limited to 'idrop-web')
-rw-r--r--idrop-web/grails-app/conf/BuildConfig.groovy1
-rw-r--r--idrop-web/grails-app/conf/spring/resources.groovy2
-rw-r--r--idrop-web/grails-app/conf/spring/resources.xml5
-rw-r--r--idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy5
-rw-r--r--idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy31
5 files changed, 29 insertions, 15 deletions
diff --git a/idrop-web/grails-app/conf/BuildConfig.groovy b/idrop-web/grails-app/conf/BuildConfig.groovy
index 7a87e96..873166a 100644
--- a/idrop-web/grails-app/conf/BuildConfig.groovy
+++ b/idrop-web/grails-app/conf/BuildConfig.groovy
@@ -28,6 +28,7 @@ grails.project.dependency.resolution = {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
test 'org.irods.jargon:jargon-test:2.4.1-SNAPSHOT'
test 'org.mockito:mockito-all:1.8.1'
+ provided 'junit:junit:4.8.1'
compile 'org.irods.jargon:jargon-core:2.4.1-SNAPSHOT'
compile 'org.irods.jargon:jargon-security:2.4.1-SNAPSHOT'
compile ('org.irods.jargon:jargon-user-tagging:2.4.1-SNAPSHOT') {
diff --git a/idrop-web/grails-app/conf/spring/resources.groovy b/idrop-web/grails-app/conf/spring/resources.groovy
index baa2acc..94d1ac8 100644
--- a/idrop-web/grails-app/conf/spring/resources.groovy
+++ b/idrop-web/grails-app/conf/spring/resources.groovy
@@ -1,9 +1,9 @@
// Place your Spring DSL code here
beans = {
-
browserController(org.irods.mydrop.controller.BrowseController) {
irodsAccessObjectFactory = ref("irodsAccessObjectFactory")
+ taggingServiceFactory = ref("taggingServiceFactory")
}
}
diff --git a/idrop-web/grails-app/conf/spring/resources.xml b/idrop-web/grails-app/conf/spring/resources.xml
index 8806efd..93b3490 100644
--- a/idrop-web/grails-app/conf/spring/resources.xml
+++ b/idrop-web/grails-app/conf/spring/resources.xml
@@ -20,6 +20,11 @@
class="org.irods.jargon.core.pub.IRODSAccessObjectFactoryImpl">
<beans:constructor-arg ref="irodsSession"></beans:constructor-arg>
</beans:bean>
+
+ <beans:bean id="taggingServiceFactory"
+ class="org.irods.jargon.usertagging.TaggingServiceFactoryImpl">
+ <beans:constructor-arg ref="irodsAccessObjectFactory"></beans:constructor-arg>
+ </beans:bean>
<beans:bean id="authenticationManager"
class="org.irods.jargon.spring.security.IRODSAccountAuthenticationManager">
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy
index 5b58f1d..b9d9dca 100644
--- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy
@@ -7,7 +7,7 @@ import org.irods.jargon.core.exception.*
import org.irods.jargon.core.pub.*
import org.irods.jargon.core.pub.domain.DataObject
import org.irods.jargon.usertagging.FreeTaggingService
-import org.irods.jargon.usertagging.FreeTaggingServiceImpl
+import org.irods.jargon.usertagging.TaggingServiceFactory
import org.springframework.security.core.context.SecurityContextHolder
@@ -19,6 +19,7 @@ import org.springframework.security.core.context.SecurityContextHolder
class BrowseController {
IRODSAccessObjectFactory irodsAccessObjectFactory
+ TaggingServiceFactory taggingServiceFactory
IRODSAccount irodsAccount
/**
@@ -110,7 +111,7 @@ class BrowseController {
log.info "is this a data object? ${isDataObject}"
- FreeTaggingService freeTaggingService = FreeTaggingServiceImpl.instance(irodsAccessObjectFactory, irodsAccount)
+ FreeTaggingService freeTaggingService = taggingServiceFactory.instanceFreeTaggingService(irodsAccount)
if (isDataObject) {
log.info("getting free tags for data object")
def freeTags = freeTaggingService.getTagsForDataObjectInFreeTagForm(absPath)
diff --git a/idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy b/idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy
index 0a01f66..695e818 100644
--- a/idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy
+++ b/idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy
@@ -1,25 +1,25 @@
package org.irods.mydrop.controller
+import grails.converters.*
import grails.test.*
-import org.irods.jargon.core.exception.JargonException
+
import java.util.Properties
+
import org.irods.jargon.core.connection.IRODSAccount
+import org.irods.jargon.core.exception.JargonException
+import org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO
import org.irods.jargon.core.pub.IRODSAccessObjectFactory
import org.irods.jargon.core.pub.IRODSFileSystem
-import org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO
-import org.irods.jargon.core.pub.io.IRODSFile
-import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry
-import org.irods.jargon.testutils.TestingPropertiesHelper
-import org.irods.jargon.testutils.filemanip.FileGenerator
-import org.irods.jargon.testutils.TestingPropertiesHelper
-import org.irods.jargon.spring.security.IRODSAuthenticationToken
import org.irods.jargon.core.pub.domain.DataObject
+import org.irods.jargon.core.query.MetaDataAndDomainData
+import org.irods.jargon.spring.security.IRODSAuthenticationToken
+import org.irods.jargon.testutils.TestingPropertiesHelper
+import org.irods.jargon.usertagging.FreeTaggingService
+import org.irods.jargon.usertagging.TaggingServiceFactory
+import org.irods.jargon.usertagging.domain.IRODSTagGrouping
import org.mockito.Mockito
import org.springframework.security.core.context.SecurityContextHolder
-import grails.converters.*
-
-
class BrowseControllerTests extends ControllerUnitTestCase {
@@ -80,10 +80,15 @@ class BrowseControllerTests extends ControllerUnitTestCase {
Mockito.when(collectionListAndSearchAO.getFullObjectForType(testPath)).thenReturn(retObject)
Mockito.when(irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)).thenReturn(collectionListAndSearchAO)
controller.irodsAccessObjectFactory = irodsAccessObjectFactory
+ FreeTaggingService freeTaggingService = Mockito.mock(FreeTaggingService.class)
+ TaggingServiceFactory taggingServiceFactory = Mockito.mock(TaggingServiceFactory.class)
+ IRODSTagGrouping grouping = new IRODSTagGrouping(MetaDataAndDomainData.MetadataDomain.DATA, "name", "tags", "user")
+ Mockito.when(freeTaggingService.getTagsForDataObjectInFreeTagForm(testPath)).thenReturn(grouping)
+ Mockito.when(taggingServiceFactory.instanceFreeTaggingService(irodsAccount)).thenReturn(freeTaggingService)
controller.irodsAccount = irodsAccount
+ controller.taggingServiceFactory = taggingServiceFactory
controller.params.absPath = testPath
controller.fileInfo()
- // FIXME: add factory for free tagging service, inject into controller to allow mocking of free tagging service
def mav = controller.modelAndView
def name = mav.viewName
@@ -92,6 +97,8 @@ class BrowseControllerTests extends ControllerUnitTestCase {
def dataObj = mav.model.dataObject
assertNotNull("null data object", dataObj)
assertEquals("did not find expected path", testPath, dataObj.dataName)
+ def tags = mav.model.tags
+ assertNotNull("null tag in model", tags)
}