Spring 프레임워크과 QueryDSL를 사용하는 환경에서
jpaQueryFactory를 사용하여 DB로부터 값을 읽어오는 Code가 있다.
이 부분에 대해 Test Code를 작성하는데
어떤식으로 Test Code를 작성해야할 지 고민이 되었다.
그래서 구글링을 하였고
Junit, Mockito and Querydsl (Mysema) for mocking JPAQueryFactory 라는 글을 찾았다.
윗글에서 해결의 실마리를 얻을 수 있었고
필자는 JUnit이 아니라 Spock을 사용하므로 Spock 문법에 맞게 바꿔서 사용했다.
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Note that you cannot sell a stock before you buy one.
Input: [7,1,5,3,6,4]
Output: 5
Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.
Not 7-1 = 6, as selling price needs to be larger than buying price.
Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).
Input: n = 00000000000000000000000000001011
Output: 3
Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits.
System.out.println(Integer.valueOf(String.valueOf(101), 2));
System.out.println(Integer.valueOf(String.valueOf(101), 8));
System.out.println(Integer.valueOf(String.valueOf(101), 10));
System.out.println(Integer.valueOf(String.valueOf(101), 16)); // 16 * 16 = 256
/*
5
65
101
257
*/
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
Input: s = "III"
Output: 3
Given two strings s and t , write a function to determine if t is an anagram of s.
Input: s = "anagram", t = "nagaram"
Output: true