Producers and Consumers subscribe to a stream of recordsProducer -> Streaming Platform -> ConsumerThe producer and consumer here are independent of ea
π Singleton A singleton class has only one instance, accessible globally through a single point(via a method/field) The main problem this pattern so
We want to move the object creation logic from our code to a separate class.We use this pattern when we do not know in advance which class we may need
Simpley move the instantiation logic to a separate class and most commonly to a static method of this class.Some do not consider simple factory to be
We have a complex process to construct an object involving multiple steps, then builder design pattern can help us.In Builder we remove the logic rela
Creational Patterns deal with process of creation of objects of classes.Structural Patterns deal with how classes and objects are arranged or composed
Definition: There should never be more than one reason for a class to changefocuses on a single functionalityaddresses a specific concernExampleProtoc
1οΈβ£ @Transactional λλΉ μλμ λ©μλλ₯Ό 보μλ©΄ λͺ¨λ κ²μ΄ μ λλ‘ νλ¬ κ°λ κ²μ λ³Ό μκ° μμ΅λλ€. λ°μ΄ν°λ² μ΄μ€λ‘λΆν° μν°ν°κ° λ°νλλ€. λ°νλ μν°ν°μ νλλ₯Ό λ³κ²½νλ€. μ‘°κ±΄μ΄ λ§λ€λ©΄ λ³κ²½ μ¬νμ λ°μ΄ν°λ² μ΄μ€λ‘ μ λ°μ΄νΈ νλ€. νμ§λ§ μ΄λ Έν μ΄μ μ
π WebSocketκ³Ό Stompλ₯Ό ν΅ν΄ μ±ν μλ² κ΅¬ν λ©μμ§ λ°©μμ μ μ μνλ€λ©΄ WebSocket λ§μΌλ‘λ μΆ©λΆν μ’μ Server/Client μμΌ μλ²λ₯Ό μμ±ν μ μμ΅λλ€. νμ§λ§ λ¨μν ν΅μ κ΅¬μ‘°λ‘ μΈν΄ WebSocketλ§μ μ΄μ©ν΄ μ±ν μ ꡬννλ©΄ ν΄λΉ
μΌλ°μ μΈ HTTP ν΅μ μ νλ μλ²λ€κ³Ό λ¬λ¦¬ μ±ν μλ²λ Socket ν΅μ μ νλ μλ²κ° νμν©λλ€. ν΅μμ μΌλ‘ HTTP ν΅μ μ Client μ μμ²μ΄ μμ λλ§ μλ²κ° μλ΅νκ³ μ°κ²°μ μ’ λ£νλ λ¨λ°©ν₯ ν΅μ μ λλ€. λ°λΌμ Client κ° Server μ μ μν΄ λ°μ΄ν°
ν μ€νΈλ₯Ό μ§ννκ² λλ©΄ ν μ€νΈ νκ²½μ λ§μΆ°μ νκ²½ μ€μ μ ν΄μ€ νμκ° μμ μ μμ΅λλ€. μ΄λ΄ λμλ src/test λλ ν°λ¦¬μ μλ‘μ΄ resources λΌλ λλ ν°λ¦¬λ₯Ό μμ±ν΄μ€λλ€. κ·Έλ¦¬κ³ ν΄λΉ λλ ν°λ¦¬μ application.yml νμΌμ μμ±ν΄μ κΈ°μ‘΄μ μ€μ λ€μ
@SpringBootTestν΄λΉ ν΄λμ€μ ν¨ν€μ§λ₯Ό νμν΄μ @SpringBootApplication μ΄λ Έν μ΄μ μ΄ μλ ν΄λμ€λ₯Ό νμνκ³ μ€νμν΅λλ€. λ§μ½ μλ€λ©΄ ν ν¨ν€μ§μ© μ€μ¬κ°λ©΄μ νμμ μ΄μ΄λκ°λλ€. ν΄λΉ μ ν리μΌμ΄μ μ μ€νμμΌ μ£Όλ―λ‘ λͺ¨λ μ»΄ν¬λνΈ(Bean)λ€
μνΈνλ νλ¬Έμ μνΈλ‘ λ§λλ κ²μ λλ€.(cipher, encrypt)볡νΈνλ μνΈλ₯Ό νλ¬ΈμΌλ‘ λ§λλ κ²μ λλ€.(decipher, decrypt)μνΈνμ μ¬μ©ν ν€μ 볡νΈνμ μ¬μ©ν ν€κ° λμΌν κ²½μ° λμΉν€ μνΈλ‘ λΆλ₯λ©λλ€.λ°λλ‘ λ€λ₯Ό κ²½μ°μλ λΉλμΉν€ μνΈλ‘ λΆλ₯λ©
νΌλΈλ¦κ³Ό νλΌμ΄λΉμ ꡬλΆμ λΈλ‘체μΈμ λ€μμ μνν μ μλμ§ νμΈνμ¬ κ²°μ :λꡬλ μ§ κΈ°λ‘λ μ 보(λΈλ‘)λ₯Ό μμ λ‘κ² μ½μ μ μλμ§?λͺ μμ μΈ λ±λ‘ λλ μ격취λ μμ΄ μ 보λ₯Ό λΈλ‘μ²΄μΈ λ€νΈμν¬μ κΈ°λ‘ν μ μλμ§?λΈλ‘체μΈμ μ λ³΄κ° κ³΅κ°λμ΄ μκ³ , λ€νΈμν¬κ° μ ν κΈ°μ€(e
μ 보λ₯Ό λΈλ‘μ΄λΌκ³ νλ λ¨μλ‘ μ μ₯νμ¬ μ μ₯λ λΈλ‘λ€μ 체μΈννλ‘ λ¬Άμ μ μ₯ κΈ°μ μ λλ€.μμμ κΈΈμ΄μ λ°μ΄ν°λ₯Ό κ³ μ λ κΈΈμ΄μ λ°μ΄ν°λ‘ λ§€ννλ ν¨μμ λλ€.ν΄μ, ν΄μ κ°, ν΄μ μ½λ = ν΄μ ν¨μμ μν΄ μ»μ΄μ§λ κ°λ°μ΄ν°λ₯Ό X, ν΄μν¨μλ₯Ό HλΌκ³ νκΈ°ν λ ν΄μλ₯Ό H(
λ§μ½ ν μ€νΈν 컨νΈλ‘€λ¬κ° μμ‘΄μ±μ΄ μλ μλΉμ€ λΉμ΄ μλ€λ©΄ μ€νλ§ λΆνΈμμ μ 곡ν΄μ£Όλ @MockBean μ΄λ Έν μ΄μ μ ν΅ν΄μ ν΄λΉ λΉμ μ£Όμ μν€κ³ Mock Objectλ‘ μμ±ν΄μ€λλ€. κ·Έλ€μμ λκ°μ΄ ν΄λΉ Mock Object κ° κ°μ§ νλ(Behavior)μ μ§μ ν΄μ£Όλ©΄
μ λ ν μ€νΈλ₯Ό ν λ 컨νΈλ‘€λ¬ λ¨λ§ ν μ€νΈ ν΄μΌνλ κ²½μ°κ° μμ΅λλ€. μ΄λ΄ λμλ μ€νλ§ λΆνΈμμ μ 곡ν΄μ£Όλ @WebMvcTest() μ MockMvc λ₯Ό μ¬μ©νλ©΄ λ©λλ€.@WebMvcTest(\[ControllerName.class])μ΄ μ΄λ Έν μ΄μ μ ν΄λμ€ μλ¨λΆμ
Mock Object λ₯Ό μμ±ν λ, μμ±ν κ°μ²΄λ μ§μ ν ν΄λμ€μ νλ(Behavior)λ₯Ό κ°μ§μ§ λͺ»ν©λλ€. μ¦, κ°λ°μκ° μ§μ ν΄λΉ κ°μ²΄μ νλμ μ§μ νμ§ μλ μ΄μ(when(), thenReturn()) ν΄λΉ κ°μ²΄κ° μννλ λͺ¨λ νλμ λν΄νΈ κ°μΌλ‘ μννκ² λ©
μ‘°κΈ λ κ²¬κ³ νκ³ μ νν ν μ€νΈλ₯Ό μ§ννκΈ° μν΄μ κ°λμ ν΄λΉ ν μ€νΈ μμμ νΉμ λ©μλλ₯Ό νΈμΆνλμ§μ λν΄μ κ²μ¦μ ν νμκ° μμ΅λλ€. μ΄λ₯Ό μν΄ Mockito μμλ verify() λΌλ ν¨μλ₯Ό μ§μν΄μ€λλ€.verify(mock).method(param);ν΄λΉ M
π Return Multiple Values λ€μμΌλ‘λ ν΄λΉ Mock Objectμ νλΌλ―Έν°μ ν¨κ» λ©μλλ₯Ό μ¬μ©ν λμλ λ€μκ³Ό κ°μ΄ μμ±νμλ©΄ λλλ°, λ§μ½ μ ν΄λμ νλΌλ―Έν°λ₯Ό μ¬μ©νμ§ μκ³ Mock Objectλ₯Ό μ¬μ©νκ² λλ©΄ μ λ¬ν κ°μ ν΄λΉνλ λν΄νΈκ°μ΄ λ°