Skip to content

Instantly share code, notes, and snippets.

View yusufcakal's full-sized avatar
:octocat:
Leave your code better than you found it

Yusuf Çakal yusufcakal

:octocat:
Leave your code better than you found it
View GitHub Profile
@yusufcakal
yusufcakal / wsdl2java.txt
Last active June 7, 2023 21:37
Helper to converting from wsdl to java
wsimport -keep -verbose -p com.yusuf.client -J-Djavax.xml.accessExternalSchema=all -J-Djavax.xml.accessExternalDTD=all 'https://example.wsdl'
@yusufcakal
yusufcakal / LoggingFilter.java
Last active February 8, 2021 08:01
Helps you easy to tracing logs to request and response via Spring
import com.dolap.settlement.model.request.CreateSettlementRequest;
import com.dolap.settlement.model.response.GetSettlementResponse;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.logging.log4j.util.Strings;
import org.slf4j.MDC;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html
Checkstyle is very configurable. Be sure to read the documentation at
@Test(expected = AddressUpdateException.class)
public void shouldNotUpdateAddressAndDoNotSendNotificationWhenAddressIdIsWrong() {
AddressUpdateRequest addressUpdateRequest = AddressUpdateRequestBuilder.anAddressUpdateRequestBuilder()
.id(1L)
.build();
when(addressRepository.findById(1L)).thenReturn(Optional.empty());
try {
addressService.update(addressUpdateRequest);
@Service
public class AddressService {
private final AddressRepository addressRepository;
private final SendNotificationService sendNotificationService;
public AddressService(AddressRepository addressRepository, SendNotificationService sendNotificationService) {
this.addressRepository = addressRepository;
this.sendNotificationService = sendNotificationService;
}
@yusufcakal
yusufcakal / SellerCenterServiceTest.java
Created August 17, 2020 04:12
SellerCenterServiceTest
@Test
public void shouldGetWorstSellerCenterLabelWhenSellerLabelOne() {
int sellCount = 3;
Seller seller = SellerBuilder.aSellerBuilder()
.sellCount(sellCount)
.previousSellerLabel(SellerLabel.SELLER_5)
.build();
when(sellerLabelTwentyProcessor.getSellerLabel(sellCount)).thenReturn(SellerLabel.NEW_SELLER);
when(sellerLabelFiveProcessor.getSellerLabel(sellCount)).thenReturn(SellerLabel.NEW_SELLER);
@yusufcakal
yusufcakal / SellerCenterServiceTest.java
Created August 16, 2020 14:31
SellerCenterServiceTest
@RunWith(MockitoJUnitRunner.class)
public class SellerCenterServiceTest {
@Mock
private SellerLabelOneProcessor sellerLabelOneProcessor;
@Mock
private SellerLabelFiveProcessor sellerLabelFiveProcessor;
@Mock
@yusufcakal
yusufcakal / SellerLabelOneProcessor.java
Last active August 18, 2020 21:00
SellerLabelOneProcessor
@Service
public class SellerLabelOneProcessor implements SellerLabelProcessor {
@Override
public SellerLabel getSellerLabel(int sellCount) {
return sellCount >= 1 && sellCount < 5 ? SellerLabel.SELLER_1 : SellerLabel.NEW_SELLER;
}
}
@yusufcakal
yusufcakal / SellerLabelFiveProcessor.java
Last active August 18, 2020 21:00
SellerLabelFiveProcessor
@Service
public class SellerLabelFiveProcessor implements SellerLabelProcessor {
@Override
public SellerLabel getSellerLabel(int sellCount) {
return sellCount >= 5 && sellCount < 20 ? SellerLabel.SELLER_5 : SellerLabel.NEW_SELLER;
}
}
@yusufcakal
yusufcakal / SellerLabelTwentyProcessor.java
Last active August 24, 2020 20:44
SellerLabelTwentyProcessor
@Service
public class SellerLabelTwentyProcessor implements SellerLabelProcessor {
@Override
public SellerLabel getSellerLabel(int sellCount) {
return sellCount >= 20 ? SellerLabel.SELLER_20 : SellerLabel.NEW_SELLER;
}
}