michaelklotz
4/30/2014 - 3:45 PM

Junit/Groovy Expected Exception

Junit/Groovy Expected Exception

 @Test
    @ExpectedException (NoLockFoundException)
    public void testGetLockInfo_Throws_Exception() {

        def mockContentDao = [
                    loadActiveContentInfoByArtifactUuid: { artifactUuid ->
                        ContentInfo contentInfo = new ContentInfo(artifactUuid)
                        contentInfo
                    }
                ] as ContentInfoDao

        ContentService contentService = new ContentServiceImpl()
        contentService. contentInfoDao = mockContentDao

        try{
            contentService.getLockInfo("I00000000000000000000000000000000" )
        } catch (NoLockFoundException){}
    }