@Test void throwsExceptionWhenBothParametersAreSpecified() { SdxRepairRequest request = new SdxRepairRequest(); request.setHostGroupName("hostgroup1"); request.setHostGroupNames(List.of("hg1", "hg2")); assertThrows(BadRequestException.class, () -> SdxRepairSettings.from(request)); }
public static SdxRepairSettings from(SdxRepairRequest request) { if (StringUtils.isNotBlank(request.getHostGroupName()) && CollectionUtils.isNotEmpty(request.getHostGroupNames())) { throw new BadRequestException("Please send only one hostGroupName in the 'hostGroupName' field " + "or multiple hostGroups in the 'hostGroupNames' fields"); } SdxRepairSettings settings = new SdxRepairSettings(); if (Strings.isNotEmpty(request.getHostGroupName())) { settings.hostGroupNames = List.of(request.getHostGroupName()); } else { settings.hostGroupNames = request.getHostGroupNames(); } return settings; }
SdxRepairSettings { public static SdxRepairSettings from(SdxRepairRequest request) { if (StringUtils.isNotBlank(request.getHostGroupName()) && CollectionUtils.isNotEmpty(request.getHostGroupNames())) { throw new BadRequestException("Please send only one hostGroupName in the 'hostGroupName' field " + "or multiple hostGroups in the 'hostGroupNames' fields"); } SdxRepairSettings settings = new SdxRepairSettings(); if (Strings.isNotEmpty(request.getHostGroupName())) { settings.hostGroupNames = List.of(request.getHostGroupName()); } else { settings.hostGroupNames = request.getHostGroupNames(); } return settings; } }
SdxRepairSettings { public static SdxRepairSettings from(SdxRepairRequest request) { if (StringUtils.isNotBlank(request.getHostGroupName()) && CollectionUtils.isNotEmpty(request.getHostGroupNames())) { throw new BadRequestException("Please send only one hostGroupName in the 'hostGroupName' field " + "or multiple hostGroups in the 'hostGroupNames' fields"); } SdxRepairSettings settings = new SdxRepairSettings(); if (Strings.isNotEmpty(request.getHostGroupName())) { settings.hostGroupNames = List.of(request.getHostGroupName()); } else { settings.hostGroupNames = request.getHostGroupNames(); } return settings; } private  SdxRepairSettings(); }
SdxRepairSettings { public static SdxRepairSettings from(SdxRepairRequest request) { if (StringUtils.isNotBlank(request.getHostGroupName()) && CollectionUtils.isNotEmpty(request.getHostGroupNames())) { throw new BadRequestException("Please send only one hostGroupName in the 'hostGroupName' field " + "or multiple hostGroups in the 'hostGroupNames' fields"); } SdxRepairSettings settings = new SdxRepairSettings(); if (Strings.isNotEmpty(request.getHostGroupName())) { settings.hostGroupNames = List.of(request.getHostGroupName()); } else { settings.hostGroupNames = request.getHostGroupNames(); } return settings; } private  SdxRepairSettings(); static SdxRepairSettings from(SdxRepairRequest request); List<String> getHostGroupNames(); }
SdxRepairSettings { public static SdxRepairSettings from(SdxRepairRequest request) { if (StringUtils.isNotBlank(request.getHostGroupName()) && CollectionUtils.isNotEmpty(request.getHostGroupNames())) { throw new BadRequestException("Please send only one hostGroupName in the 'hostGroupName' field " + "or multiple hostGroups in the 'hostGroupNames' fields"); } SdxRepairSettings settings = new SdxRepairSettings(); if (Strings.isNotEmpty(request.getHostGroupName())) { settings.hostGroupNames = List.of(request.getHostGroupName()); } else { settings.hostGroupNames = request.getHostGroupNames(); } return settings; } private  SdxRepairSettings(); static SdxRepairSettings from(SdxRepairRequest request); List<String> getHostGroupNames();  }