Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package end2end.broker.rankings
- import org.joda.time.DateTime
- import helper.UserStepHelpers
- import helper.base.BaseAcceptanceSpec
- import core.models.RankingUser
- import core.models.User
- import com.timgroup.test.narrative._
- import RespondTo.respond_to
- import RankingRequestBuilder.the_ranking_request
- import RankingResultsRequestBuilder.the_ranking_results_request
- import RankingIdeasRequestBuilder.the_ranking_ideas_request
- import IdeaHistoryRequestBuilder.the_idea_history_request
- import ViewingUser.viewing
- import ViewTheRankingPage.view_the_rankings_page
- import TheRankingNames.the_ranking_names
- import ChooseTheRankingNamed.choose_the_ranking_named
- import ChooseTheBrokerWithId.choose_the_broker_with_id
- import ChooseTheIdeaWithId.choose_the_idea_with_id
- import TheSelectedRankings.the_selected_rankings
- import TheRankingsBrokerIds.the_rankings_broker_ids
- import TheSelectedBrokerIdeaIds.the_selected_broker_idea_ids
- import TheSelectedIdeaHistoryId.the_selected_idea_history_id
- import RankingsXmlBuilder.a_ranking_xml
- import ARankingBuilder.a_ranking_named
- import ARankingBuilder.a_ranking
- import RankingResultsXmlBuilder.a_ranking_results_xml
- import ARankingResultBuilder.a_ranking_result
- import IdeasXmlBuilder.an_ideas_xml
- import AnIdeaBuilder.an_idea_with_id
- import AnIdeaBuilder.an_idea
- import AnIdeaHistoryBuilder.an_idea_history_with_id
- class RankingsSpec extends BaseAcceptanceSpec with UserStepHelpers {
- val equities_service = new StubEquitiesServiceActor
- describe("Can see the users' rankings") {
- val firstDate = new DateTime(2013, 3, 5, 12, 55)
- val secondDate = new DateTime(2013, 3, 5, 17, 55)
- def randomUser() = usersRepo.insert(randomUsername, RankingUser).get
- it("First rankings have the expected brokers") {
- val user = randomUser()
- val viewer = viewing(user)
- Given.the(equities_service)
- .was_able_to(respond_to(the_ranking_request.for_user(user))
- .with_response(a_ranking_xml.containing(a_ranking_named("MTD").with_id("mtd"))
- .containing(a_ranking_named("YTD").with_id("ytd")).get()))
- .was_able_to(respond_to(the_ranking_results_request.for_user(user)
- .and_ranking("mtd"))
- .with_response(a_ranking_results_xml.containing(a_ranking_result.for_broker_id("broker-1")
- .with_rank(13))
- .containing(a_ranking_result.for_broker_id("broker-2")
- .with_rank(25)).get()))
- When.the(viewer).attempts_to(view_the_rankings_page)
- Then.the(viewer).expects_that(the_ranking_names)(_ should equal(List("MTD", "YTD")))
- .and_that(the_rankings_broker_ids)(_ should equal(List("broker-1", "broker-2")))
- }
- it("Selected Rankings' Brokers are Present") {
- val user = randomUser()
- val viewer = viewing(user)
- Given.the(equities_service)
- .was_able_to(respond_to(the_ranking_request.for_user(user))
- .with_response(a_ranking_xml.containing(a_ranking_named("MTD").with_id("mtd"))
- .containing(a_ranking_named("YTD").with_id("ytd")).get()))
- .was_able_to(respond_to(the_ranking_results_request.for_user(user)
- .and_ranking("mtd"))
- .with_response(a_ranking_results_xml.get()))
- .was_able_to(respond_to(the_ranking_results_request.for_user(user)
- .and_ranking("ytd"))
- .with_response(a_ranking_results_xml.containing(a_ranking_result.for_broker_id("broker-3")
- .with_rank(5))
- .containing(a_ranking_result.for_broker_id("broker-4")
- .with_rank(11)).get()))
- When.the(viewer).attempts_to(view_the_rankings_page)
- .and_to(choose_the_ranking_named("YTD"))
- Then.the(viewer).expects_that(the_selected_rankings)(_ should be(List("YTD")))
- .and_that(the_rankings_broker_ids)(_ should equal(List("broker-3", "broker-4")))
- }
- it("Second Broker's Ideas are Present after selecting the Second Broker") {
- val user = randomUser()
- val viewer = viewing(user)
- Given.the(equities_service)
- .was_able_to(respond_to(the_ranking_request.for_user(user))
- .with_response(a_ranking_xml.containing(a_ranking(name = "MTD", id = "mtd")).get()))
- .was_able_to(respond_to(the_ranking_results_request.for_user(user)
- .and_ranking("mtd"))
- .with_response(a_ranking_results_xml.containing(a_ranking_result(brokerId = "broker-1",
- rank = 13))
- .containing(a_ranking_result(brokerId = "broker-2",
- rank = 25)).get()))
- .was_able_to(respond_to(the_ranking_ideas_request.for_user(user)
- .and_criteria("mtd")
- .and_contributor("broker-2"))
- .with_response(an_ideas_xml.containing(an_idea(id = "idea-c", lastAction = secondDate))
- .containing(an_idea(id = "idea-d", lastAction = firstDate)).get()))
- When.the(viewer).attempts_to(view_the_rankings_page)
- .and_to(choose_the_broker_with_id("broker-2"))
- Then.the(viewer).expects_that(the_selected_broker_idea_ids)(_ should be(List("idea-c", "idea-d")))
- }
- it("Idea details are present when selecting an Idea") {
- val user = randomUser()
- val ideaHistory = an_idea_history_with_id("idea-c-history").get()
- val viewer = viewing(user)
- Given.the(equities_service)
- .was_able_to(respond_to(the_ranking_request.for_user(user))
- .with_response(a_ranking_xml.containing(a_ranking_named("MTD").with_id("mtd")).get()))
- .was_able_to(respond_to(the_ranking_results_request.for_user(user)
- .and_ranking("mtd"))
- .with_response(a_ranking_results_xml.containing(a_ranking_result.for_broker_id("broker-1")
- .with_rank(13))
- .containing(a_ranking_result.for_broker_id("broker-2")
- .with_rank(25)).get()))
- .was_able_to(respond_to(the_ranking_ideas_request.for_user(user)
- .and_criteria("mtd")
- .and_contributor("broker-2"))
- .with_response(an_ideas_xml.containing(an_idea_with_id("idea-c").with_last_action_on(secondDate))
- .containing(an_idea_with_id("idea-d").with_last_action_on(firstDate)).get()))
- .was_able_to(respond_to(the_idea_history_request.for_user(user)
- .and_idea("idea-c"))
- .with_response(ideaHistory))
- When.the(viewer).attempts_to(view_the_rankings_page)
- .and_to(choose_the_broker_with_id("broker-2"))
- .and_to(choose_the_idea_with_id("idea-c"))
- Then.the(viewer).expects_that(the_selected_idea_history_id)(_ should be("idea-c-history"))
- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement