public void testCreateHITWithInvalidReviewPolicy() throws ServiceException { // create a SKA policy that is missing required parameter AnswerKey ReviewPolicy assignmentReviewPolicy = new ReviewPolicy("ScoreMyKnownAnswers/2011-09-01", new PolicyParameter[] {}); try { service.createHIT( null, // hitTypeId defaultHITTitle + unique, defaultHITDescription, null, // keywords RequesterService.getBasicFreeTextQuestion(defaultQuestion), defaultReward, defaultAssignmentDurationInSeconds, defaultAutoApprovalDelayInSeconds, defaultLifetimeInSeconds, defaultMaxAssignments, null, // requesterAnnotation null, // qualificationRequirements null, // responseGroup null, // uniqueRequestToken assignmentReviewPolicy, null); // hitReviewPolicy fail("createHIT succeeded, despite having an invalid review policy"); } catch (ServiceException e) { // expected assertTrue("createHIT failed, but not because of an invalid review policy", e.getMessage().contains("The AnswerKey parameter is mandatory.")); } }
public void testCreateHITWithReviewPolicy() throws ServiceException { /* Create some review policies. * The policy details are nonsense and are not asserted on -- this test * just verifies that (1) the act of plugging in a review policy does not * cause createHIT to blow up, and that (2) said review policies appear in * the HIT's review results. */ PolicyParameter[] skaParams = { new PolicyParameter("AnswerKey", null, new ParameterMapEntry[] { new ParameterMapEntry("1", new String[] {"correct answer"}) }) }; ReviewPolicy assignmentReviewPolicy = new ReviewPolicy("ScoreMyKnownAnswers/2011-09-01", skaParams); PolicyParameter[] phrParams = { new PolicyParameter("QuestionIds", new String[] {"1"}, null), new PolicyParameter("QuestionAgreementThreshold", new String[] {"50"}, null), }; ReviewPolicy hitReviewPolicy = new ReviewPolicy("SimplePlurality/2011-09-01", phrParams); // Create the HIT with review policies HIT hit = service.createHIT( null, // hitTypeId defaultHITTitle + unique, defaultHITDescription, null, // keywords RequesterService.getBasicFreeTextQuestion(defaultQuestion), defaultReward, defaultAssignmentDurationInSeconds, defaultAutoApprovalDelayInSeconds, defaultLifetimeInSeconds, defaultMaxAssignments, null, // requesterAnnotation null, // qualificationRequirements null, // responseGroup null, // uniqueRequestToken assignmentReviewPolicy, hitReviewPolicy); // Make sure the policies were actually added to the created HIT GetReviewResultsForHITResult results = service.getReviewResultsForHIT( hit.getHITId(), new ReviewPolicyLevel[] {ReviewPolicyLevel.Assignment, ReviewPolicyLevel.HIT}, true, // retrieveActions true, // retrieveResults 1, // pageNumber 1000, // pageSize null); // responseGroup assertEquals("Unexpected assignment policy", results.getAssignmentReviewPolicy().getPolicyName(), "ScoreMyKnownAnswers/2011-09-01"); assertEquals("Unexpected HIT policy", results.getHITReviewPolicy().getPolicyName(), "SimplePlurality/2011-09-01"); }