11package org .rulez .demokracia .pdengine ;
22
3- import static org .junit .Assert .fail ;
4-
53import org .junit .Test ;
64import org .rulez .demokracia .pdengine .annotations .TestedBehaviour ;
75import org .rulez .demokracia .pdengine .annotations .TestedFeature ;
86import org .rulez .demokracia .pdengine .annotations .TestedOperation ;
7+ import org .rulez .demokracia .pdengine .exception .ReportedException ;
98import org .rulez .demokracia .pdengine .testhelpers .CreatedDefaultVoteRegistry ;
109
1110public class ForShowVoteTheUserNeedsACountedAssurance extends CreatedDefaultVoteRegistry {
1211
12+ public ForShowVoteTheUserNeedsACountedAssurance () {
13+ super ();
14+ }
15+
16+ @ Test
17+ @ TestedFeature ("Manage votes" )
18+ @ TestedOperation ("show vote" )
19+ @ TestedBehaviour ("if adminKey is anon, the user should have any of the countedAssurances" )
20+ public void a_user_with_not_all_assourances_cannot_show_the_vote () throws ReportedException {
21+
22+ Vote vote = getTheVote ();
23+ vote .countedAssurances .add ("german" );
24+
25+ assertAssurancesMissing (vote );
26+ }
27+
1328 @ Test
1429 @ TestedFeature ("Manage votes" )
1530 @ TestedOperation ("show vote" )
1631 @ TestedBehaviour ("if adminKey is anon, the user should have any of the countedAssurances" )
17- public void create_creates_a_vote_with_countedAssurances () {
18-
32+ public void a_user_with_not_all_assourances_cannot_show_the_vote_even_with_more_assurances () throws ReportedException {
33+
1934 Vote vote = getTheVote ();
20- vote .adminKey = "user" ;
21- vote .countedAssurances .add (ASSURANCE_NAME );
22- if (!("user" .equals (vote .adminKey )
23- && vote .neededAssurances .containsAll (countedAssurances ))) {
24- fail ("anon admin key without countedAssurances" );
25- }
35+ vote .countedAssurances .add ("magyar" );
36+ vote .countedAssurances .add ("german" );
37+
38+ assertAssurancesMissing (vote );
39+ }
40+
41+ private void assertAssurancesMissing (Vote vote ) {
42+ // assertThrows(
43+ // () -> voteManager.showVote(vote.id, "user")
44+ // ).assertMessageIs("missing assurances");
2645 }
27- }
46+ }
0 commit comments