Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/main/java/video/domain/Movie.java

This file was deleted.

25 changes: 25 additions & 0 deletions src/main/java/video/domain/movie/Movie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package video.domain.movie;

public class Movie {

private String title;
MovieType movieType;


public Movie(String title, MovieType movieType) {
this.title = title;
this.movieType = movieType;
}

public String getTitle() {
return title;
}

public int amount(int daysRented) {
return movieType.amount(daysRented);
}

public int frequentRenterPoints(int daysRented) {
return movieType.frequentRenterPoints(daysRented);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package video.domain;
package video.domain.movie;

import video.domain.point.ChildrenPoint;
import video.domain.point.NewReleasePoint;
Expand All @@ -9,15 +9,15 @@
import video.domain.price.Price;
import video.domain.price.RegularPrice;

public enum PriceType {
public enum MovieType {
CHILDREN(new ChildrenPrice(), new ChildrenPoint()),
REGULAR(new RegularPrice(), new RegularPoint()),
NEW_RELEASE(new NewReleasePrice(), new NewReleasePoint());

Price price;
Point point;

PriceType(Price price, Point point) {
MovieType(Price price, Point point) {
this.price = price;
this.point = point;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/video/domain/rental/Rental.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package video.domain.rental;

import video.domain.Movie;
import video.domain.movie.Movie;

public class Rental {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package video.infrastructure.datasource.data;

import video.domain.Movie;
import video.domain.movie.Movie;

public record RentalItem(Movie movie, int days) {
}
8 changes: 5 additions & 3 deletions src/test/java/video/domain/CustomerTest.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package video.domain;

import org.junit.jupiter.api.Test;
import video.domain.movie.Movie;
import video.domain.movie.MovieType;
import video.domain.rental.Rental;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;

class CustomerTest {

Movie 子供用作品_となりのトトロ = new Movie("となりのトトロ", PriceType.CHILDREN);
Movie 旧作_トップガン = new Movie("トップガン", PriceType.REGULAR);
Movie 新作_君たちはどう生きるか = new Movie("君たちはどう生きるか", PriceType.NEW_RELEASE);
Movie 子供用作品_となりのトトロ = new Movie("となりのトトロ", MovieType.CHILDREN);
Movie 旧作_トップガン = new Movie("トップガン", MovieType.REGULAR);
Movie 新作_君たちはどう生きるか = new Movie("君たちはどう生きるか", MovieType.NEW_RELEASE);

@Test
void 新作と旧作と子供用作品のレンタル() {
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/video/domain/price/ChildrenPriceTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package video.domain.price;

import org.junit.jupiter.api.Test;
import video.domain.Movie;
import video.domain.PriceType;
import video.domain.movie.Movie;
import video.domain.movie.MovieType;
import video.domain.rental.Rental;

import static org.junit.jupiter.api.Assertions.assertEquals;

class ChildrenPriceTest {

Movie 子供用作品_となりのトトロ = new Movie("となりのトトロ", PriceType.CHILDREN);
Movie 子供用作品_となりのトトロ = new Movie("となりのトトロ", MovieType.CHILDREN);
@Test
void 子供用作品を4日のレンタル料金() {
Rental sut = new Rental(子供用作品_となりのトトロ, 4);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/video/domain/price/NewReleasePriceTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package video.domain.price;

import org.junit.jupiter.api.Test;
import video.domain.Movie;
import video.domain.PriceType;
import video.domain.movie.Movie;
import video.domain.movie.MovieType;
import video.domain.rental.Rental;

import static org.junit.jupiter.api.Assertions.assertEquals;

class NewReleasePriceTest {

Movie 新作_君たちはどう生きるか = new Movie("君たちはどう生きるか", PriceType.NEW_RELEASE);
Movie 新作_君たちはどう生きるか = new Movie("君たちはどう生きるか", MovieType.NEW_RELEASE);

@Test
void 新作を4日のレンタル料金() {
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/video/domain/price/RegularPriceTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package video.domain.price;

import org.junit.jupiter.api.Test;
import video.domain.Movie;
import video.domain.PriceType;
import video.domain.movie.Movie;
import video.domain.movie.MovieType;
import video.domain.rental.Rental;

import static org.junit.jupiter.api.Assertions.assertEquals;

class RegularPriceTest {

Movie 旧作_トップガン = new Movie("トップガン", PriceType.REGULAR);
Movie 旧作_トップガン = new Movie("トップガン", MovieType.REGULAR);

@Test
void 旧作を2日のレンタル料金() {
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/video/domain/rental/RentalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import video.domain.Movie;
import video.domain.PriceType;
import video.domain.movie.Movie;
import video.domain.movie.MovieType;

import static org.junit.jupiter.api.Assertions.assertEquals;

class RentalTest {

Movie 子供用作品_となりのトトロ = new Movie("となりのトトロ", PriceType.CHILDREN);
Movie 旧作_トップガン = new Movie("トップガン", PriceType.REGULAR);
Movie 新作_君たちはどう生きるか = new Movie("君たちはどう生きるか", PriceType.NEW_RELEASE);
Movie 子供用作品_となりのトトロ = new Movie("となりのトトロ", MovieType.CHILDREN);
Movie 旧作_トップガン = new Movie("トップガン", MovieType.REGULAR);
Movie 新作_君たちはどう生きるか = new Movie("君たちはどう生きるか", MovieType.NEW_RELEASE);

@Nested
class レンタル料金テスト {
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/video/domain/rental/RentalsTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package video.domain.rental;

import org.junit.jupiter.api.Test;
import video.domain.Movie;
import video.domain.PriceType;
import video.domain.movie.Movie;
import video.domain.movie.MovieType;

import static org.junit.jupiter.api.Assertions.assertEquals;

class RentalsTest {
Movie 子供用作品_となりのトトロ = new Movie("となりのトトロ", PriceType.CHILDREN);
Movie 旧作_トップガン = new Movie("トップガン", PriceType.REGULAR);
Movie 新作_君たちはどう生きるか = new Movie("君たちはどう生きるか", PriceType.NEW_RELEASE);
Movie 子供用作品_となりのトトロ = new Movie("となりのトトロ", MovieType.CHILDREN);
Movie 旧作_トップガン = new Movie("トップガン", MovieType.REGULAR);
Movie 新作_君たちはどう生きるか = new Movie("君たちはどう生きるか", MovieType.NEW_RELEASE);

@Test
void 合計金額の算出() {
Expand Down