forked from smallrye/smallrye-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request smallrye#1395 from phillip-kruger/main
Sync with 1.5.x
- Loading branch information
Showing
13 changed files
with
295 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...k/src/test/java/io/smallrye/graphql/test/apps/generics/inheritance/api/AbstractHasID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.smallrye.graphql.test.apps.generics.inheritance.api; | ||
|
||
public abstract class AbstractHasID<I extends ID<I>> { | ||
protected I id; | ||
|
||
public I getId() { | ||
return this.id; | ||
} | ||
|
||
public void setId(I id) { | ||
this.id = id; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../tck/src/test/java/io/smallrye/graphql/test/apps/generics/inheritance/api/AbstractID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.smallrye.graphql.test.apps.generics.inheritance.api; | ||
|
||
public abstract class AbstractID<I extends ID<I>> { | ||
|
||
private String id; | ||
|
||
public AbstractID(final String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getValue() { | ||
return this.id; | ||
} | ||
|
||
public void setValue(String id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.id; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
server/tck/src/test/java/io/smallrye/graphql/test/apps/generics/inheritance/api/Film.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package io.smallrye.graphql.test.apps.generics.inheritance.api; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Film extends AbstractHasID<TestID> { | ||
|
||
private String title; | ||
private Integer episode; | ||
private String director; | ||
private LocalDate releaseDate; | ||
|
||
public Film() { | ||
|
||
} | ||
|
||
public Film( | ||
final TestID id, | ||
final String title, | ||
final int episode, | ||
final String director, | ||
final LocalDate releaseDate) { | ||
this.id = id; | ||
this.title = title; | ||
this.episode = episode; | ||
this.director = director; | ||
this.releaseDate = releaseDate; | ||
} | ||
|
||
public String getTitle() { | ||
return this.title; | ||
} | ||
|
||
public Integer getEpisode() { | ||
return this.episode; | ||
} | ||
|
||
public String getDirector() { | ||
return this.director; | ||
} | ||
|
||
public LocalDate getReleaseDate() { | ||
return this.releaseDate; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public void setEpisode(Integer episode) { | ||
this.episode = episode; | ||
} | ||
|
||
public void setDirector(String director) { | ||
this.director = director; | ||
} | ||
|
||
public void setReleaseDate(LocalDate releaseDate) { | ||
this.releaseDate = releaseDate; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
|
||
sb.append("Id: ").append(this.id.toString()).append("\n"); | ||
sb.append("Title: ").append(this.title).append("\n"); | ||
sb.append("Episode: ").append(this.episode).append("\n"); | ||
sb.append("Director: ").append(this.director).append("\n"); | ||
sb.append("ReleaseDate: ").append(this.releaseDate).append("\n"); | ||
|
||
return sb.toString(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ck/src/test/java/io/smallrye/graphql/test/apps/generics/inheritance/api/FilmResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.smallrye.graphql.test.apps.generics.inheritance.api; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Mutation; | ||
import org.eclipse.microprofile.graphql.Query; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
@GraphQLApi | ||
public class FilmResource { | ||
|
||
@Inject | ||
FilmService service; | ||
|
||
@Query("allFilms") | ||
public Uni<List<Film>> getFilms() { | ||
return this.service.getFilms(); | ||
} | ||
|
||
@Mutation | ||
public Uni<Boolean> addFilm(final Film f) { | ||
return this.service.addFilm(f); | ||
} | ||
|
||
@Mutation | ||
public Uni<Boolean> deleteFilm(int id) { | ||
return this.service.deleteFilm(id); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...tck/src/test/java/io/smallrye/graphql/test/apps/generics/inheritance/api/FilmService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.smallrye.graphql.test.apps.generics.inheritance.api; | ||
|
||
import java.time.LocalDate; | ||
import java.time.Month; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
@ApplicationScoped | ||
public class FilmService { | ||
|
||
private List<Film> films = new ArrayList<>(); | ||
|
||
public FilmService() { | ||
Film aNewHope = new Film( | ||
new TestID("1"), "A New Hope", 4, "George Lucas", LocalDate.of(1977, Month.JANUARY, 25)); | ||
|
||
Film theEmpireStrikesBack = new Film( | ||
new TestID("2"), "The Empire Strikes Back", 5, "Irvin Kershner", LocalDate.of(1980, | ||
Month.MARCH, 17)); | ||
|
||
Film returnOfTheJedi = new Film( | ||
new TestID("3"), "Return of the Jedi", 6, "Richard Marquand", LocalDate.of(1983, Month.MAY, | ||
25)); | ||
|
||
films.add(aNewHope); | ||
films.add(theEmpireStrikesBack); | ||
films.add(returnOfTheJedi); | ||
} | ||
|
||
public Uni<List<Film>> getFilms() { | ||
System.out.println("Films get method called"); | ||
|
||
for (Film f : films) { | ||
System.out.println(f); | ||
} | ||
|
||
return Uni.createFrom().item(this.films); | ||
} | ||
|
||
public Uni<Boolean> addFilm(Film f) { | ||
return Uni.createFrom().item(this.films.add(f)); | ||
} | ||
|
||
public Uni<Boolean> deleteFilm(int id) { | ||
try { | ||
this.films.remove(id); | ||
return Uni.createFrom().item(true); | ||
} | ||
|
||
catch (IndexOutOfBoundsException | UnsupportedOperationException e) { | ||
return Uni.createFrom().item(false); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
server/tck/src/test/java/io/smallrye/graphql/test/apps/generics/inheritance/api/ID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.smallrye.graphql.test.apps.generics.inheritance.api; | ||
|
||
public interface ID<I extends ID<I>> { | ||
|
||
// Marker interface. | ||
} |
Oops, something went wrong.