Skip to content

Instantly share code, notes, and snippets.

View mzakyalvan's full-sized avatar

Muhammad Zaky Alvan mzakyalvan

View GitHub Profile

Notes

Ignore Files

No need to include target build directory into scm commit. Check them into scm can cause bigger repo size, drive longer time to check out fresh project copy.

Some IDE specific project (.idea directory or *.iml files) configuration might cause problems on other computers, for example file path incompatibility. Following .gitignore is enough for each module.

#Sharing Session

Introduction

Muhammad Zaky Alvan (zaky.alvan@tiket.com)

BDD Brief

BDD is extension of TDD, which write test failing test first, then implement system and/or components under tests, make the tests passes and iterate.

package sample;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
package sample;
import io.reactivex.Single;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class SimulateTimeout {
public static void main(String[] args) throws Exception {
SimulateTimeout sample = new SimulateTimeout();
package sample;
import java.util.ArrayList;
import java.util.List;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
public class CombiningSample {
public static void main(String[] args) {
package com.tiket.poc;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
public class MockitoTests {
@mzakyalvan
mzakyalvan / DemoApplication.java
Last active November 23, 2018 09:24
Strategy pattern sample
package com.example.demo;
import io.reactivex.Flowable;
import io.reactivex.Single;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@mzakyalvan
mzakyalvan / SimpleObjectCachingTests.java
Created December 4, 2018 16:19
Caching sample using reactor extra's ```reactor.cache.CacheMono```
package reactor.caching;
import org.junit.Test;
import reactor.cache.CacheMono;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Signal;
import reactor.test.StepVerifier;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
@mzakyalvan
mzakyalvan / CaffeineBackedCachingTests.java
Created December 5, 2018 01:21
How to use project-reactor's CacheMono which backed by Caffeine cache.
package reactor.caching;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.Expiry;
import lombok.Builder;
import lombok.Getter;
import org.junit.Test;
import org.mockito.Mockito;
import reactor.cache.CacheMono;
package com.tiket.poc.swagger;
import java.util.List;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
public class MockitoVerifyParametersTests {