Append import bundle link to repository type if unbundle command is supported

This commit is contained in:
Eduard Heimbuch
2020-12-10 10:36:08 +01:00
parent 89add3f795
commit 097237734e
3 changed files with 38 additions and 2 deletions

View File

@@ -112,4 +112,31 @@ public class RepositoryTypeToRepositoryTypeDtoMapperTest {
RepositoryTypeDto dto = mapper.map(type);
assertFalse(dto.getLinks().getLinkBy("import").isPresent());
}
@Test
public void shouldAppendImportFromBundleLink() {
RepositoryType type = new RepositoryType("hk", "Hitchhiker", ImmutableSet.of(Command.UNBUNDLE));
when(subject.isPermitted("repository:create")).thenReturn(true);
RepositoryTypeDto dto = mapper.map(type);
assertEquals(
"https://scm-manager.org/scm/v2/repositories/import/hk/bundle",
dto.getLinks().getLinkBy("import").get().getHref()
);
}
@Test
public void shouldNotAppendImportFromBundleLinkIfCommandNotSupported() {
when(subject.isPermitted("repository:create")).thenReturn(true);
RepositoryTypeDto dto = mapper.map(type);
assertFalse(dto.getLinks().getLinkBy("import").isPresent());
}
@Test
public void shouldNotAppendImportFromBundleLinkIfNotPermitted() {
RepositoryType type = new RepositoryType("hk", "Hitchhiker", ImmutableSet.of(Command.UNBUNDLE));
RepositoryTypeDto dto = mapper.map(type);
assertFalse(dto.getLinks().getLinkBy("import").isPresent());
}
}