Last active
January 22, 2020 20:21
-
-
Save kimberleehowley/cbb1c01e3b5de51a43a3302a5eca01e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.testguide | |
import com.testguide.CampaignService | |
import com.testguide.User | |
import com.testguide.dataservice.UserDataService | |
import grails.testing.mixin.integration.Integration | |
import grails.web.servlet.mvc.GrailsParameterMap | |
import org.springframework.mock.web.MockHttpServletRequest | |
import org.springframework.test.annotation.Rollback | |
import org.springframework.transaction.annotation.Transactional | |
import spock.lang.Specification | |
/** | |
* Test class for {@link CampaignService} | |
*/ | |
@Integration | |
@Transactional | |
@Rollback | |
class CampaignServiceSpec extends Specification { | |
UserDataService userDataService | |
//class under test | |
CampaignService campaignService | |
def setup() {//for this spec the setup does not have to do anything | |
} | |
void "list all campaigns"() { | |
given: "a user" | |
User user = userDataService.findById(1) | |
and: "an instance of GrailsParameterMap" | |
def requestParams = [startDate: '2019-03-06', endDate: '2019-03-08'] | |
MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest() | |
mockHttpServletRequest.parameters = requestParams | |
mockHttpServletRequest.getParameterMap() | |
def params = new GrailsParameterMap(mockHttpServletRequest) | |
when: "a call to list campaigns is made" | |
Tuple2 result = campaignService.list(user, params) | |
then: "result" | |
result | |
and: "it contains the campaign list" | |
result.first.campaignList | |
and: "the campaign list is 3" | |
result.first.campaignList.size() == 3 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment