Last active
April 3, 2020 08:24
-
-
Save bnbaek/ce38326b0dbbf5cbd6e6ab189fdc030d to your computer and use it in GitHub Desktop.
enum-test
This file contains hidden or 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
package io.barogo.zoo.core.repository.coffee; | |
import io.barogo.zoo.core.config.db.envers.JpaAuditingConfig; | |
import io.barogo.zoo.core.config.db.querydsl.QuerydslConfiguration; | |
import io.barogo.zoo.core.repository.test.Coffee; | |
import io.barogo.zoo.core.repository.test.CoffeeRepository; | |
import io.barogo.zoo.core.repository.test.CoffeeType; | |
import io.barogo.zoo.open.Application; | |
import io.barogo.zoo.open.config.security.ResourceConfig; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.Optional; | |
import org.junit.Assert; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.autoconfigure.domain.EntityScan; | |
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | |
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | |
import org.springframework.test.context.ContextConfiguration; | |
import org.springframework.test.context.junit4.SpringRunner; | |
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | |
/** | |
* Created by BNBAEK | |
* Package : io.barogo.zoo.core.repository.payment | |
* User: dean | |
* Date: 2020/02/23 | |
* Time: 8:38 오후 | |
*/ | |
@RunWith(SpringRunner.class) | |
@DataJpaTest | |
@EnableJpaRepositories("io.barogo.zoo") | |
@EntityScan("io.barogo.zoo") | |
@ContextConfiguration(classes = {Application.class, ResourceConfig.class, QuerydslConfiguration.class, JpaAuditingConfig.class}) | |
public class CoffeeRepositoryTest { | |
@Autowired | |
CoffeeRepository coffeeRepository; | |
@Test | |
public void ENUM테스트() { | |
//given | |
CoffeeType message = CoffeeType.MESSAGE; | |
Coffee coffee = new Coffee(message); | |
//when | |
Coffee savedCoffee = coffeeRepository.save(coffee); | |
//then | |
System.out.println("saved coffee = "+savedCoffee.toString()); | |
assertThat(savedCoffee.getId()).isGreaterThan(0); | |
assertThat(savedCoffee.getType()).isEqualTo(message); | |
Coffee findCoffee = coffeeRepository.findByType(message).get(); | |
System.out.println("Find Coffe type >"+findCoffee.getType()); | |
} | |
} |
This file contains hidden or 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
Hibernate: | |
insert | |
into | |
zoo_coffee | |
(coffee_id, type) | |
values | |
(null, ?) | |
2020-04-03 17:23:11.835 TRACE [open-api-service,,,] 11803 --- [ Test worker] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [VARCHAR] - [2] | |
saved coffee = Coffee(id=1, type=MESSAGE) | |
Hibernate: | |
select | |
coffee0_.coffee_id as coffee_i1_1_, | |
coffee0_.type as type2_1_ | |
from | |
zoo_coffee coffee0_ | |
where | |
coffee0_.type=? | |
2020-04-03 17:23:11.913 TRACE [open-api-service,,,] 11803 --- [ Test worker] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [VARCHAR] - [2] | |
2020-04-03 17:23:11.914 TRACE [open-api-service,,,] 11803 --- [ Test worker] o.h.type.descriptor.sql.BasicExtractor : extracted value ([coffee_i1_1_] : [BIGINT]) - [1] | |
Find Coffe type >MESSAGE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment