@Test
@Transactional
public void testCleanApp() throws Exception {

  final Library lib = this.createExampleLibrary();
  this.libRepository.customSave(lib);
  Application app = this.createExampleApplication();
  app = this.appRepository.customSave(app);
  // Repo must contain 1
  assertEquals(1, this.appRepository.count());
  // Rest-post
  final MockHttpServletRequestBuilder post_builder =
      post(getAppUri(app)).param("clean", "true").accept(MediaType.APPLICATION_JSON);
  mockMvc
      .perform(post_builder)
      .andExpect(status().isOk())
      .andExpect(content().contentType(contentTypeJson));
  // Repo must contain 1
  assertEquals(1, this.appRepository.count());
  // Check that there are no constructs and dependencies any more
  final Application managed_app = this.appRepository.findOne(app.getId());
  final Boolean isEmpty =
      (managed_app.getConstructs() == null || managed_app.getConstructs().isEmpty())
          && (managed_app.getDependencies() == null || managed_app.getDependencies().isEmpty());
  assertEquals(true, isEmpty);
}