@Test public void testCreateInstrument() throws Exception { // Arrange DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject(); this.dataAcquisitionProjectRepository.save(project); Instrument instrument = UnitTestCreateDomainObjectUtils.buildInstrument(project.getId(), "SurveyId"); // Act and Assert // create the instrument with the given id mockMvc .perform( put(API_INSTRUMENTS_URI + "/" + instrument.getId()) .content(TestUtil.convertObjectToJsonBytes(instrument))) .andExpect(status().isCreated()); elasticsearchUpdateQueueService.processQueue(); // check that there are two instrument documents elasticsearchAdminService.refreshAllIndices(); assertThat(elasticsearchAdminService.countAllDocuments(), equalTo(2.0)); // check that auditing attributes have been set mockMvc .perform(get(API_INSTRUMENTS_URI + "/" + instrument.getId())) .andExpect(status().isOk()) .andExpect(jsonPath("$.createdDate", not(isEmptyOrNullString()))) .andExpect(jsonPath("$.lastModifiedDate", not(isEmptyOrNullString()))) .andExpect(jsonPath("$.createdBy", is("system"))) .andExpect(jsonPath("$.lastModifiedBy", is("system"))); // call toString for test coverage :-| instrument.toString(); }