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
public enum SellerLabel { | |
NEW_SELLER, | |
SELLER_1, | |
SELLER_5, | |
SELLER_20; | |
public boolean isSellerLabelNotNewSeller() { | |
return SellerLabel.NEW_SELLER != this; | |
} |
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
public interface SellerLabelProcessor { | |
SellerLabel getSellerLabel(int sellCount); | |
} |
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
@Service | |
public class SellerCenterService { | |
private final List<SellerLabelProcessor> sellerLabelProcessors; | |
public SellerCenterService(List<SellerLabelProcessor> sellerLabelProcessors) { | |
this.sellerLabelProcessors = sellerLabelProcessors; | |
} | |
public SellerCenterLabel getSellerCenterLabel(Seller seller) { |
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
<dependency> | |
<groupId>org.mockito</groupId> | |
<artifactId>mockito-core</artifactId> | |
<version>${mockito-core.version}</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> |
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
@DisplayName("should convert from page type to notification type") | |
public class PageTypeNotificationTypeListConverterTest { | |
@ParameterizedTest | |
@MethodSource("pageTypeMapped") | |
public void shouldConvertPageTypeToNotificationType(PageType pageType, List<NotificationType> notificationTypes) { | |
final PageTypeNotificationTypeListConverter pageTypeNotificationTypeListConverter = new PageTypeNotificationTypeListConverter(); | |
assertEquals(notificationTypes, pageTypeNotificationTypeListConverter.convert(pageType)); | |
} |
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
import java.util.Calendar; | |
import java.util.Date; | |
public final class Clock { | |
private static boolean isFrozen; | |
private static Date timeSet; | |
private Clock() { |
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
@Configuration | |
@EnableTransactionManagement | |
public class DatabaseConfiguration { | |
@Bean | |
@Primary | |
@Profile("!test") | |
@DependsOn({"primaryDataSource", "replicaDataSource"}) | |
public DataSource dataSource(@Qualifier("primaryDataSource") HikariDataSource primaryDataSource, | |
@Qualifier("replicaDataSource") HikariDataSource replicaDataSource) { |
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
@Component | |
public class RequestResponseLoggingInterceptor implements ClientHttpRequestInterceptor { | |
private final Logger log = LoggerFactory.getLogger(this.getClass()); | |
@Override | |
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { | |
logRequest(request, body); | |
ClientHttpResponse response = execution.execute(request, body); | |
logResponse(response); |
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
public class TextMasker { | |
public static String mask(String text, int begin, int end) { | |
if (Objects.isNull(text)) { | |
return null; | |
} | |
if (areIndexesInBoundOfText(text, begin, end)) { | |
String firstDisplayablePart = text.substring(0, begin); | |
String secondDisplayablePart = text.substring(end); |
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
@Component | |
public class Slf4jMDCFilter extends OncePerRequestFilter { | |
@Override | |
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws java.io.IOException, ServletException { | |
MDC.put("requestId", "Request ID: " + UUID.randomUUID().toString()); | |
chain.doFilter(request, response); | |
} | |
} |