@Test public void testCreateRelatedPublications() throws IOException, Exception { // ARRANGE RelatedPublication relatedPublication = UnitTestCreateDomainObjectUtils.buildRelatedPublication(); // ACT // create the related publication with the given id this.mockMvc .perform( put(API_RELATED_PUBLICATION_URI + "/" + relatedPublication.getId()) .content(TestUtil.convertObjectToJsonBytes(relatedPublication))) .andExpect(status().isCreated()); // ASSERT // read the related publication under the new url this.mockMvc .perform(get(API_RELATED_PUBLICATION_URI + "/" + relatedPublication.getId())) .andExpect(status().isOk()); elasticsearchUpdateQueueService.processQueue(); // check that there are two data set documents plus two surveys elasticsearchAdminService.refreshAllIndices(); assertThat(elasticsearchAdminService.countAllDocuments(), equalTo(2.0)); }
@Test public void testUpdateStudyWithInvalidReleaseDoi() throws IOException, Exception { // ARRANGE RelatedPublication relatedPublication = UnitTestCreateDomainObjectUtils.buildRelatedPublication(); relatedPublication.setDoi( "ThisDoiIsTooLong.ThisDoiIsTooLong.ThisDoiIsTooLong.ThisDoiIsTooLong.ThisDoiIsTooLong.ThisDoiIsTooLong.ThisDoiIsTooLong." + "ThisDoiIsTooLong.ThisDoiIsTooLong.ThisDoiIsTooLong.ThisDoiIsTooLong.ThisDoiIsTooLong."); // ACT and ASSERT // create the related publication with the given id this.mockMvc .perform( put(API_RELATED_PUBLICATION_URI + "/" + relatedPublication.getId()) .content(TestUtil.convertObjectToJsonBytes(relatedPublication))) .andExpect(status().is4xxClientError()); }