From 0504f75dfe1a22297a5f7ba5cc49d9207df42c0d Mon Sep 17 00:00:00 2001 From: slefebvre Date: Fri, 8 Dec 2023 15:49:54 +0100 Subject: [PATCH] Missing test sources --- .../test/sequence/t0003jakarta/Movie.java | 53 +++++++++++++++ .../test/sequence/t0003jakarta/MovieDAO.java | 65 +++++++++++++++++++ .../sequence/t0003jakarta/MovieService.java | 16 +++++ 3 files changed, 134 insertions(+) create mode 100644 plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/Movie.java create mode 100644 plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieDAO.java create mode 100644 plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieService.java diff --git a/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/Movie.java b/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/Movie.java new file mode 100644 index 00000000..400034d8 --- /dev/null +++ b/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/Movie.java @@ -0,0 +1,53 @@ +package de.elnarion.test.sequence.t0003jakarta; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "MOVIE") +public class Movie { + + @Id + private Long id; + + private String movieName; + + private Integer releaseYear; + + private String language; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMovieName() { + return movieName; + } + + public void setMovieName(String movieName) { + this.movieName = movieName; + } + + public Integer getReleaseYear() { + return releaseYear; + } + + public void setReleaseYear(Integer releaseYear) { + this.releaseYear = releaseYear; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + +} diff --git a/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieDAO.java b/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieDAO.java new file mode 100644 index 00000000..9a14c163 --- /dev/null +++ b/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieDAO.java @@ -0,0 +1,65 @@ +package de.elnarion.test.sequence.t0003jakarta; + +import java.util.List; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; + +public class MovieDAO { + + @PersistenceContext + private + EntityManager entityManager; + + + public void saveMovie(de.elnarion.test.sequence.t0003jakarta.Movie paramMovie) { + EntityManager em = getEntityManager(); + + em.getTransaction().begin(); + + em.persist(paramMovie); + em.getTransaction().commit(); + } + + public de.elnarion.test.sequence.t0003jakarta.Movie getMovie(Long movieId) { + EntityManager em = getEntityManager(); + de.elnarion.test.sequence.t0003jakarta.Movie movie = em.find(de.elnarion.test.sequence.t0003jakarta.Movie.class, Long.valueOf(movieId)); + em.detach(movie); + return movie; + } + + public void changeMovieLanguage(Long paramId, String paramLanguage) { + EntityManager em = getEntityManager(); + de.elnarion.test.sequence.t0003jakarta.Movie movie = getMovie(paramId); + em.detach(movie); + movie.setLanguage(paramLanguage); + em.getTransaction().begin(); + em.merge(movie); + em.getTransaction().commit(); + } + + public List queryForMovies() { + EntityManager em = getEntityManager(); + List movies = em.createQuery("SELECT movie from Movie movie where movie.language = ?1") + .setParameter(1, "English") + .getResultList(); + return movies; + } + + public void removeMovie() { + EntityManager em = getEntityManager(); + em.getTransaction().begin(); + de.elnarion.test.sequence.t0003jakarta.Movie movie = em.find(de.elnarion.test.sequence.t0003jakarta.Movie.class, Long.valueOf(1L)); + em.remove(movie); + em.getTransaction().commit(); + } + + public EntityManager getEntityManager() { + return entityManager; + } + + + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } +} diff --git a/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieService.java b/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieService.java new file mode 100644 index 00000000..23fb09fe --- /dev/null +++ b/plantuml-generator-util/src/test/java/de/elnarion/test/sequence/t0003jakarta/MovieService.java @@ -0,0 +1,16 @@ +package de.elnarion.test.sequence.t0003jakarta; + +import de.elnarion.test.sequence.t0003.Movie; +import de.elnarion.test.sequence.t0003.MovieDAO; + +public class MovieService { + + MovieDAO movieDAO; + + public void doSomeBusiness() { + Movie movie = movieDAO.getMovie((long) 111); + movie.setMovieName("asdfasdfasdf"); + movieDAO.saveMovie(movie); + } + +}