append optional dependencies to webapp dto

This commit is contained in:
Konstantin Schaper
2020-07-22 09:55:57 +02:00
parent b51ddae59d
commit b3d5f930ea
3 changed files with 11 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ public class PluginDto extends HalRepresentation {
private Boolean core;
private Boolean markedForUninstall;
private Set<String> dependencies;
private Set<String> optionalDependencies;
public PluginDto(Links links) {
add(links);

View File

@@ -68,6 +68,7 @@ public abstract class PluginDtoMapper {
private void map(PluginDto dto, Plugin plugin) {
dto.setDependencies(plugin.getDescriptor().getDependencies());
dto.setOptionalDependencies(plugin.getDescriptor().getOptionalDependencies());
map(plugin.getDescriptor().getInformation(), dto);
if (dto.getCategory() == null) {
dto.setCategory("Miscellaneous");

View File

@@ -164,6 +164,15 @@ class PluginDtoMapperTest {
assertThat(dto.getDependencies()).containsOnly("one", "two");
}
@Test
void shouldAppendOptionalDependencies() {
AvailablePlugin plugin = createAvailable(createPluginInformation());
when(plugin.getDescriptor().getOptionalDependencies()).thenReturn(ImmutableSet.of("one", "two"));
PluginDto dto = mapper.mapAvailable(plugin);
assertThat(dto.getOptionalDependencies()).containsOnly("one", "two");
}
@Test
void shouldAppendUninstallLink() {
when(subject.isPermitted("plugin:write")).thenReturn(true);