@Test
public void successDeleteBundle() throws Exception {
BundleMetadata bundleMetadata = new BundleMetadata.Builder().name("ToDelete").build();
bundleService.save(bundleMetadata);
final long previousSize = bundleService.getAll().size();
final long previousRevision = revisionService.getLatest();
assertThat(bundleService.getAll().size(), Matchers.equalTo(1));
assertThat(bundleMetadata.getUuid(), not(Matchers.isEmptyOrNullString()));
assertThat(bundleMetadata.getTag(), not(Matchers.isEmptyOrNullString()));
assertTrue(Files.exists(fileSystem.getPath(props.getBasePath(), BundleDaoImpl.ENTITY_NAME, bundleMetadata.getUuid() + ".yaml")));
assertNotNull(bundleService.getByTag(bundleMetadata.getTag()));
mockMvc.perform(deleteAuthenticated("/bundle/" + bundleMetadata.getTag()))
.andExpect(status().isOk());
mockMvc.perform(deleteAuthenticated("/bundle/" + bundleMetadata.getTag()))
.andExpect(status().isNotFound());
assertFalse(Files.exists(fileSystem.getPath(props.getBasePath(), BundleDaoImpl.ENTITY_NAME, bundleMetadata.getUuid() + ".yaml")));
assertNull(bundleService.getByTag(bundleMetadata.getTag()));
assertEquals(previousSize - 1, bundleService.getAll().size());
assertEquals(previousRevision + 1, revisionService.getLatest());
List<Revision> revisions = revisionService.getDiffs(previousRevision);
assertThat(revisions, IsCollectionWithSize.hasSize(1));
Revision revision = revisions.get(0);
assertEquals(revision.getAction(), Revision.Action.DELETE);
assertEquals(((long) revision.getRevision()), previousRevision + 1);
assertEquals(revision.getType(), Revision.Type.BUNDLE);
assertEquals(revision.getTarget(), bundleMetadata.getUuid());
assertEquals(revision.getResult(), null);
}
BundleControllerDeleteTest.java 文件源码
java
阅读 34
收藏 0
点赞 0
评论 0
项目:dashboard
作者:
评论列表
文章目录