### Question:
CommandEntity extends BaseEntity { public void addApplication(@NotNull final ApplicationEntity application) throws PreconditionFailedException { if (this.applications.contains(application)) { throw new PreconditionFailedException( "An application with id " + application.getUniqueId() + " is already added" ); } this.applications.add(application); application.getCommands().add(this); } CommandEntity(); void setExecutable(@NotEmpty final List<@NotBlank @Size(max = 1024) String> executable); void setConfigs(@Nullable final Set<FileEntity> configs); void setDependencies(@Nullable final Set<FileEntity> dependencies); void setTags(@Nullable final Set<TagEntity> tags); Optional<Integer> getMemory(); Optional<JsonNode> getLauncherExt(); void setLauncherExt(@Nullable final JsonNode launcherExt); void setApplications(
        @Nullable final List<ApplicationEntity> applications
    ); void addApplication(@NotNull final ApplicationEntity application); void removeApplication(@NotNull final ApplicationEntity application); void setClusterCriteria(@Nullable final List<CriterionEntity> clusterCriteria); void addClusterCriterion(final CriterionEntity criterion); void addClusterCriterion(final CriterionEntity criterion, final int priority); CriterionEntity removeClusterCriterion(final int priority); @Override boolean equals(final Object o); @Override int hashCode(); static final String APPLICATIONS_ENTITY_GRAPH; static final String APPLICATIONS_DTO_ENTITY_GRAPH; static final String CLUSTER_CRITERIA_ENTITY_GRAPH; static final String DTO_ENTITY_GRAPH; }### Answer:
@Test void canAddApplication() throws PreconditionFailedException { final String id = UUID.randomUUID().toString(); final ApplicationEntity app = new ApplicationEntity(); app.setUniqueId(id); this.c.addApplication(app); Assertions.assertThat(this.c.getApplications()).contains(app); Assertions.assertThat(app.getCommands()).contains(this.c); }
@Test void cantAddApplicationThatAlreadyIsInList() throws PreconditionFailedException { final String id = UUID.randomUUID().toString(); final ApplicationEntity app = new ApplicationEntity(); app.setUniqueId(id); this.c.addApplication(app); Assertions .assertThatExceptionOfType(PreconditionFailedException.class) .isThrownBy(() -> this.c.addApplication(app)); }