diff options
author | Mike Conway <mikeconway@Mike-Conways-MacBook-Pro.local> | 2011-02-26 14:38:43 (GMT) |
---|---|---|
committer | Mike Conway <mikeconway@Mike-Conways-MacBook-Pro.local> | 2011-02-26 14:38:43 (GMT) |
commit | 96e279c64fbc4807da8929fbbb36f5a2ae718e33 (patch) | |
tree | 7d605892331849b8edb4f4539ebe760769444f0b | |
parent | 79f94dffa929f75c077eadd615b35abffb3f7466 (diff) | |
download | QCG-Data-96e279c64fbc4807da8929fbbb36f5a2ae718e33.zip QCG-Data-96e279c64fbc4807da8929fbbb36f5a2ae718e33.tar.gz QCG-Data-96e279c64fbc4807da8929fbbb36f5a2ae718e33.tar.bz2 |
unit tests for update tags idrop web
-rw-r--r-- | idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy | 6 | ||||
-rw-r--r-- | idrop-web/grails-app/services/mydrop/UserTagService.groovy | 10 | ||||
-rw-r--r-- | idrop-web/grails-app/taglib/org/irods/mydrop/taglib/AuthTagLib.groovy (renamed from idrop-web/grails-app/taglib/AuthTagLib.groovy) | 3 | ||||
-rw-r--r-- | idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy | 26 | ||||
-rw-r--r-- | idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy | 3 |
5 files changed, 31 insertions, 17 deletions
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy index def8612..13cf60c 100644 --- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy +++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy @@ -51,11 +51,11 @@ class TagsController { * update the tag for the collection or data object based on a free tag string */ def updateTags = { - def absPath = params['absPath'] + String absPath = params['absPath'] def tagString = params['tags'] - if (absPath == null || absPath.length == 0) { + if (absPath == null || absPath.isEmpty()) { throw new JargonException("no absPath passed to method") } @@ -66,7 +66,7 @@ class TagsController { log.info("updating tags for file: ${absPath} for user: ${irodsAccount.userName}") FreeTaggingService freeTaggingService = taggingServiceFactory.instanceFreeTaggingService(irodsAccount) - freeTaggingService.updateTagsForUserForADataObjectOrCollection(absPath, irodsAccount.userName, tags) + freeTaggingService.updateTagsForUserForADataObjectOrCollection(absPath, irodsAccount.userName, tagString) log.info("tags updated") } diff --git a/idrop-web/grails-app/services/mydrop/UserTagService.groovy b/idrop-web/grails-app/services/mydrop/UserTagService.groovy deleted file mode 100644 index 1d9bdb0..0000000 --- a/idrop-web/grails-app/services/mydrop/UserTagService.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package mydrop - -class UserTagService { - - static transactional = false - - def buildUserTagCloud() { - - } -} diff --git a/idrop-web/grails-app/taglib/AuthTagLib.groovy b/idrop-web/grails-app/taglib/org/irods/mydrop/taglib/AuthTagLib.groovy index fee2283..58e03b1 100644 --- a/idrop-web/grails-app/taglib/AuthTagLib.groovy +++ b/idrop-web/grails-app/taglib/org/irods/mydrop/taglib/AuthTagLib.groovy @@ -1,5 +1,4 @@ - -import org.springframework.security.core.context.SecurityContextHolder +package org.irods.mydrop.taglib class AuthTagLib { diff --git a/idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy b/idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy index ed2f326..5407068 100644 --- a/idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy +++ b/idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy @@ -11,6 +11,7 @@ import org.irods.jargon.core.connection.IRODSAccount import org.irods.jargon.core.pub.IRODSAccessObjectFactory import org.irods.jargon.core.pub.IRODSFileSystem import org.irods.jargon.testutils.TestingPropertiesHelper +import org.irods.jargon.usertagging.FreeTaggingService; import org.irods.jargon.usertagging.UserTagCloudService import org.irods.jargon.usertagging.domain.UserTagCloudView import org.irods.jargon.usertagging.domain.IRODSTagValue @@ -61,4 +62,29 @@ class TagsControllerTests extends ControllerUnitTestCase { assertNotNull("null tagView in model", tagView) } + + void testUpdateTags() { + testingPropertiesHelper = new TestingPropertiesHelper() + testingProperties = testingPropertiesHelper.getTestProperties() + irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties) + FreeTaggingService freeTaggingService = Mockito.mock(FreeTaggingService.class) + TaggingServiceFactory taggingServiceFactory = Mockito.mock(TaggingServiceFactory.class) + //Mockito.when(freeTaggingService.updateTagsForUserForADataObjectOrCollection(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + Mockito.when(taggingServiceFactory.instanceFreeTaggingService(irodsAccount)).thenReturn(freeTaggingService) + controller.irodsAccessObjectFactory = irodsAccessObjectFactory + controller.taggingServiceFactory = taggingServiceFactory + controller.irodsAccount = irodsAccount + def tags = "tag1 tag2 tag3" + def user = irodsAccount.getUserName() + def absPath = "abspath" + controller.params.absPath = absPath + controller.params.tags = tags + controller.updateTags() + Mockito.verify(freeTaggingService).updateTagsForUserForADataObjectOrCollection(absPath, user, tags) + + + } + + + } diff --git a/idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy b/idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy index 479b6e9..39902a8 100644 --- a/idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy +++ b/idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy @@ -1,5 +1,4 @@ package org.irods.mydrop.taglib - import grails.test.* class AuthTagLibTests extends TagLibUnitTestCase { @@ -12,6 +11,6 @@ class AuthTagLibTests extends TagLibUnitTestCase { } void testSomething() { - + } } |