@Test
public void testPublishMultiple() throws Exception {

    allowedRepository.deleteAll();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.getSession();
    String ids = Joiner.on(",").join(this.metadataIds);
    PublishReport report = publishService.publish("eng", request, ids, false);
    assertCorrectReport(report, 3, 0, 0, 0);
    report = publishService.publish("eng", request, ids, false);
    assertCorrectReport(report, 0, 0, 3, 0);
    allowedRepository.deleteAll(OperationAllowedSpecs.hasMetadataId(this.metadataIds.get(0)));
    report = publishService.publish("eng", request, ids, false);
    assertCorrectReport(report, 1, 0, 2, 0);
    allowedRepository.deleteAll(OperationAllowedSpecs.hasMetadataId(this.metadataIds.get(0)));
    SecurityContextHolder.clearContext();
    report = publishService.publish("eng", request, ids, false);
    assertCorrectReport(report, 0, 0, 2, 1);
}