@Test public void getRequiredPermissions() { PatchApplication patchApplication = new PatchApplication(); assertEquals(Collections.emptySet(), patchApplication.getRequiredPermissions()); patchApplication.setName(Optional.of("patchName")); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_SETTINGS)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); patchApplication.setDescription(Optional.of("patchDescription")); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_SETTINGS)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); patchApplication.setEnabled(Optional.of(true)); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_SETTINGS)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); patchApplication.setTemplate(Optional.of(true)); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_SETTINGS)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); patchApplication.setIdentities(Optional.of(Collections.singleton("patchIdentity"))); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_IDENTITY_PROVIDER)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); patchApplication.setFactors(Optional.of(Collections.singleton("patchFactor"))); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_FACTOR)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); patchApplication.setCertificate(Optional.of("patchCertificate")); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_CERTIFICATE)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); patchApplication.setMetadata(Optional.of(Collections.emptyMap())); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_SETTINGS)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); PatchApplicationSettings patchApplicationSettings = new PatchApplicationSettings(); patchApplication.setSettings(Optional.of(patchApplicationSettings)); assertEquals(Collections.emptySet(), patchApplication.getRequiredPermissions()); patchApplicationSettings.setOauth(Optional.of(new PatchApplicationOAuthSettings())); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_OPENID)), patchApplication.getRequiredPermissions()); patchApplicationSettings.setOauth(Optional.empty()); patchApplicationSettings.setAccount(Optional.of(new AccountSettings())); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_SETTINGS)), patchApplication.getRequiredPermissions()); patchApplicationSettings.setAccount(Optional.empty()); patchApplicationSettings.setAdvanced(Optional.of(new PatchApplicationAdvancedSettings())); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_SETTINGS)), patchApplication.getRequiredPermissions()); patchApplication = new PatchApplication(); patchApplication.setTemplate(Optional.of(true)); patchApplication.setIdentities(Optional.of(Collections.singleton("patchIdentity"))); patchApplication.setFactors(Optional.of(Collections.singleton("patchFactor"))); patchApplication.setCertificate(Optional.of("patchCertificate")); patchApplicationSettings = new PatchApplicationSettings(); patchApplicationSettings.setOauth(Optional.of(new PatchApplicationOAuthSettings())); patchApplication.setSettings(Optional.of(patchApplicationSettings)); assertEquals(new HashSet<>(Arrays.asList(Permission.APPLICATION_SETTINGS, Permission.APPLICATION_OPENID, Permission.APPLICATION_IDENTITY_PROVIDER, Permission.APPLICATION_CERTIFICATE, Permission.APPLICATION_FACTOR)), patchApplication.getRequiredPermissions()); }
public Set<Permission> getRequiredPermissions() { Set<Permission> requiredPermissions = new HashSet<>(); if (name != null && name.isPresent() || description != null && description.isPresent() || enabled != null && enabled.isPresent() || template != null && template.isPresent() || metadata != null && metadata.isPresent()) { requiredPermissions.add(Permission.APPLICATION_SETTINGS); } if (identities != null && identities.isPresent()) { requiredPermissions.add(Permission.APPLICATION_IDENTITY_PROVIDER); } if (factors != null && factors.isPresent()) { requiredPermissions.add(Permission.APPLICATION_FACTOR); } if (certificate != null && certificate.isPresent()) { requiredPermissions.add(Permission.APPLICATION_CERTIFICATE); } if (settings != null && settings.isPresent()) { requiredPermissions.addAll(settings.get().getRequiredPermissions()); } return requiredPermissions; }
PatchApplication { public Set<Permission> getRequiredPermissions() { Set<Permission> requiredPermissions = new HashSet<>(); if (name != null && name.isPresent() || description != null && description.isPresent() || enabled != null && enabled.isPresent() || template != null && template.isPresent() || metadata != null && metadata.isPresent()) { requiredPermissions.add(Permission.APPLICATION_SETTINGS); } if (identities != null && identities.isPresent()) { requiredPermissions.add(Permission.APPLICATION_IDENTITY_PROVIDER); } if (factors != null && factors.isPresent()) { requiredPermissions.add(Permission.APPLICATION_FACTOR); } if (certificate != null && certificate.isPresent()) { requiredPermissions.add(Permission.APPLICATION_CERTIFICATE); } if (settings != null && settings.isPresent()) { requiredPermissions.addAll(settings.get().getRequiredPermissions()); } return requiredPermissions; } }
PatchApplication { public Set<Permission> getRequiredPermissions() { Set<Permission> requiredPermissions = new HashSet<>(); if (name != null && name.isPresent() || description != null && description.isPresent() || enabled != null && enabled.isPresent() || template != null && template.isPresent() || metadata != null && metadata.isPresent()) { requiredPermissions.add(Permission.APPLICATION_SETTINGS); } if (identities != null && identities.isPresent()) { requiredPermissions.add(Permission.APPLICATION_IDENTITY_PROVIDER); } if (factors != null && factors.isPresent()) { requiredPermissions.add(Permission.APPLICATION_FACTOR); } if (certificate != null && certificate.isPresent()) { requiredPermissions.add(Permission.APPLICATION_CERTIFICATE); } if (settings != null && settings.isPresent()) { requiredPermissions.addAll(settings.get().getRequiredPermissions()); } return requiredPermissions; }  }
PatchApplication { public Set<Permission> getRequiredPermissions() { Set<Permission> requiredPermissions = new HashSet<>(); if (name != null && name.isPresent() || description != null && description.isPresent() || enabled != null && enabled.isPresent() || template != null && template.isPresent() || metadata != null && metadata.isPresent()) { requiredPermissions.add(Permission.APPLICATION_SETTINGS); } if (identities != null && identities.isPresent()) { requiredPermissions.add(Permission.APPLICATION_IDENTITY_PROVIDER); } if (factors != null && factors.isPresent()) { requiredPermissions.add(Permission.APPLICATION_FACTOR); } if (certificate != null && certificate.isPresent()) { requiredPermissions.add(Permission.APPLICATION_CERTIFICATE); } if (settings != null && settings.isPresent()) { requiredPermissions.addAll(settings.get().getRequiredPermissions()); } return requiredPermissions; }  Optional<String> getName(); void setName(Optional<String> name); Optional<String> getDescription(); void setDescription(Optional<String> description); Optional<Boolean> getEnabled(); void setEnabled(Optional<Boolean> enabled); Optional<Boolean> getTemplate(); void setTemplate(Optional<Boolean> template); Optional<Set<String>> getIdentities(); void setIdentities(Optional<Set<String>> identities); Optional<Set<String>> getFactors(); void setFactors(Optional<Set<String>> factors); Optional<String> getCertificate(); void setCertificate(Optional<String> certificate); Optional<Map<String, Object>> getMetadata(); void setMetadata(Optional<Map<String, Object>> metadata); Optional<PatchApplicationSettings> getSettings(); void setSettings(Optional<PatchApplicationSettings> settings); Application patch(Application _toPatch); Set<Permission> getRequiredPermissions(); }
PatchApplication { public Set<Permission> getRequiredPermissions() { Set<Permission> requiredPermissions = new HashSet<>(); if (name != null && name.isPresent() || description != null && description.isPresent() || enabled != null && enabled.isPresent() || template != null && template.isPresent() || metadata != null && metadata.isPresent()) { requiredPermissions.add(Permission.APPLICATION_SETTINGS); } if (identities != null && identities.isPresent()) { requiredPermissions.add(Permission.APPLICATION_IDENTITY_PROVIDER); } if (factors != null && factors.isPresent()) { requiredPermissions.add(Permission.APPLICATION_FACTOR); } if (certificate != null && certificate.isPresent()) { requiredPermissions.add(Permission.APPLICATION_CERTIFICATE); } if (settings != null && settings.isPresent()) { requiredPermissions.addAll(settings.get().getRequiredPermissions()); } return requiredPermissions; }  Optional<String> getName(); void setName(Optional<String> name); Optional<String> getDescription(); void setDescription(Optional<String> description); Optional<Boolean> getEnabled(); void setEnabled(Optional<Boolean> enabled); Optional<Boolean> getTemplate(); void setTemplate(Optional<Boolean> template); Optional<Set<String>> getIdentities(); void setIdentities(Optional<Set<String>> identities); Optional<Set<String>> getFactors(); void setFactors(Optional<Set<String>> factors); Optional<String> getCertificate(); void setCertificate(Optional<String> certificate); Optional<Map<String, Object>> getMetadata(); void setMetadata(Optional<Map<String, Object>> metadata); Optional<PatchApplicationSettings> getSettings(); void setSettings(Optional<PatchApplicationSettings> settings); Application patch(Application _toPatch); Set<Permission> getRequiredPermissions();  }