'링크모음 > Swift' 카테고리의 다른 글
swift defer 예제 (0) | 2017.10.22 |
---|---|
swift4 tour (0) | 2017.10.22 |
swift 에서 self 값 체크 (0) | 2017.10.18 |
pod update/install 시 라이버러리를 전부 강제 3.2로 세팅하기 (0) | 2017.10.16 |
Contributing to Swift (0) | 2017.08.30 |
swift defer 예제 (0) | 2017.10.22 |
---|---|
swift4 tour (0) | 2017.10.22 |
swift 에서 self 값 체크 (0) | 2017.10.18 |
pod update/install 시 라이버러리를 전부 강제 3.2로 세팅하기 (0) | 2017.10.16 |
Contributing to Swift (0) | 2017.08.30 |
fabric에 오류 보내기 (0) | 2017.10.25 |
---|---|
안드로이드 클린 아키텍쳐 관련 링크 모음 (0) | 2017.10.24 |
Android google todo mvp uml 이미지 (0) | 2017.10.16 |
android 클린 아키텍쳐 모음 (0) | 2017.10.15 |
WeakReference 와 SoftReference 차이점 (0) | 2017.09.27 |
{ [weak self] offset in
guard let `self` = self else { return false } //<-- 체크..
swift4 tour (0) | 2017.10.22 |
---|---|
노티피케이션 사용법 (0) | 2017.10.20 |
pod update/install 시 라이버러리를 전부 강제 3.2로 세팅하기 (0) | 2017.10.16 |
Contributing to Swift (0) | 2017.08.30 |
Object C -> Swift 로 변환해주는 온라인 사이트!! (0) | 2017.08.24 |
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.2'
end
end
end
swift4 tour (0) | 2017.10.22 |
---|---|
노티피케이션 사용법 (0) | 2017.10.20 |
swift 에서 self 값 체크 (0) | 2017.10.18 |
Contributing to Swift (0) | 2017.08.30 |
Object C -> Swift 로 변환해주는 온라인 사이트!! (0) | 2017.08.24 |
안드로이드 클린 아키텍쳐 관련 링크 모음 (0) | 2017.10.24 |
---|---|
메트리얼 디자인 정리 글 (0) | 2017.10.18 |
android 클린 아키텍쳐 모음 (0) | 2017.10.15 |
WeakReference 와 SoftReference 차이점 (0) | 2017.09.27 |
안드로이드 디버깅 툴 총정리 (0) | 2017.09.27 |
클린 아키텍쳐상에서 RxJava 적용
https://fernandocejas.com/2015/07/18/architecting-android-the-evolution/
메트리얼 디자인 정리 글 (0) | 2017.10.18 |
---|---|
Android google todo mvp uml 이미지 (0) | 2017.10.16 |
WeakReference 와 SoftReference 차이점 (0) | 2017.09.27 |
안드로이드 디버깅 툴 총정리 (0) | 2017.09.27 |
포토샵에서 이미지를 안드로이드 레이아웃 형식으로 넣기 (0) | 2017.09.14 |
RxSwift publish , connect , share , refcount (0) | 2017.08.31 |
---|---|
rxswift Single, Maybe, Completable 사용법 (0) | 2017.08.10 |
RxSwift 기본 #2 (0) | 2017.08.10 |
RxSwift 기본 #1 (0) | 2017.08.10 |
RxSwift Single,Maybe등 사용설명 (0) | 2017.08.10 |
분명 비어있는 데 trim 을 했을 경우 안없어지는 경우가 발생할 수 있다.
그럴경우 아래 함수를 실행해보자.
public static String trimAdvanced(String value) {
Objects.requireNonNull(value);
int strLength = value.length();
int len = value.length();
int st = 0;
char[] val = value.toCharArray();
if (strLength == 0) {
return "";
}
while ((st < len) && (val[st] <= ' ') || (val[st] == '\u00A0')) {
st++;
if (st == strLength) {
break;
}
}
while ((st < len) && (val[len - 1] <= ' ') || (val[len - 1] == '\u00A0')) {
len--;
if (len == 0) {
break;
}
}
return (st > len) ? "" : ((st > 0) || (len < strLength)) ? value.substring(st, len) : value;
}
java9 빠르게 핵심만 (0) | 2017.11.07 |
---|---|
대표적인 소프트웨어 아키텍쳐 10가지 (0) | 2017.09.15 |
DTO와 VO 차이점.. (0) | 2017.08.09 |
Android google todo mvp uml 이미지 (0) | 2017.10.16 |
---|---|
android 클린 아키텍쳐 모음 (0) | 2017.10.15 |
안드로이드 디버깅 툴 총정리 (0) | 2017.09.27 |
포토샵에서 이미지를 안드로이드 레이아웃 형식으로 넣기 (0) | 2017.09.14 |
Android , View component 설계 및 내용 (0) | 2017.09.12 |
하나의 아이템이 배출되면 다른 모든게 배출되도록 하기 (0) | 2017.11.20 |
---|---|
[RxJava2]Backpressure 의 함수들을 알아보자 (0) | 2017.10.22 |
RxJava2 함수 간단 예제 모음 (0) | 2017.09.15 |
Rxjava2 Collection 예제 (0) | 2017.09.15 |
RxJava Extection 라이버러리 (0) | 2017.09.15 |
android 클린 아키텍쳐 모음 (0) | 2017.10.15 |
---|---|
WeakReference 와 SoftReference 차이점 (0) | 2017.09.27 |
포토샵에서 이미지를 안드로이드 레이아웃 형식으로 넣기 (0) | 2017.09.14 |
Android , View component 설계 및 내용 (0) | 2017.09.12 |
TDD 흐름도 (0) | 2017.09.08 |
[RxJava2]Backpressure 의 함수들을 알아보자 (0) | 2017.10.22 |
---|---|
RxJava 를 활용한 효과적인 네트워크 체크 풀링 (0) | 2017.09.27 |
Rxjava2 Collection 예제 (0) | 2017.09.15 |
RxJava Extection 라이버러리 (0) | 2017.09.15 |
Rxjava를 활용한 두개의 리스트 항목 비교 (0) | 2017.09.14 |
RxJava 를 활용한 효과적인 네트워크 체크 풀링 (0) | 2017.09.27 |
---|---|
RxJava2 함수 간단 예제 모음 (0) | 2017.09.15 |
RxJava Extection 라이버러리 (0) | 2017.09.15 |
Rxjava를 활용한 두개의 리스트 항목 비교 (0) | 2017.09.14 |
RxAndroid 활용한 라이버러리 모음 (0) | 2017.09.14 |
RxJava2 함수 간단 예제 모음 (0) | 2017.09.15 |
---|---|
Rxjava2 Collection 예제 (0) | 2017.09.15 |
Rxjava를 활용한 두개의 리스트 항목 비교 (0) | 2017.09.14 |
RxAndroid 활용한 라이버러리 모음 (0) | 2017.09.14 |
RxJava를 활용한 페이징(Paging) (0) | 2017.09.13 |
java9 빠르게 핵심만 (0) | 2017.11.07 |
---|---|
java trim() 이 안먹힐때.. (0) | 2017.09.28 |
DTO와 VO 차이점.. (0) | 2017.08.09 |
우아한 형제들 기술 블로그
http://woowabros.github.io/woowabros/2017/09/12/realtime-service.html
docker + mongodb 를 윈도우에서 세팅방법 (0) | 2018.05.03 |
---|---|
CORS, Preflight, 인증 처리 관련 삽질 [펌글,링크] (0) | 2017.12.05 |
WeakReference 와 SoftReference 차이점 (0) | 2017.09.27 |
---|---|
안드로이드 디버깅 툴 총정리 (0) | 2017.09.27 |
Android , View component 설계 및 내용 (0) | 2017.09.12 |
TDD 흐름도 (0) | 2017.09.08 |
안드로이드 소스 모음 사이트 (0) | 2017.09.03 |
출처 : https://stackoverflow.com/a/43343039
Observable<String> observable1 = Observable.from(new String[]{"A", "B", "C", "D"});
Observable<String> observable2 = Observable.from(new String[]{"E", "C", "B", "G", "J", "O"});
observable1.concatMap(new Func1<String, Observable<Boolean>>() {
@Override
public Observable<Boolean> call(final String string) {
return observable2.contains(string);
}
}).zipWith(observable1, new Func2<Boolean, String, String>() {
@Override
public String call(final Boolean contains, final String string) {
return contains ? "" : string;
}
}).filter(new Func1<String, Boolean>() {
@Override
public Boolean call(final String string) {
return !TextUtils.isEmpty(string);
}
}).subscribe(new Action1<String>() {
@Override
public void call(final String string) {
Log.d("observable:", string);
}
});
Rxjava2 Collection 예제 (0) | 2017.09.15 |
---|---|
RxJava Extection 라이버러리 (0) | 2017.09.15 |
RxAndroid 활용한 라이버러리 모음 (0) | 2017.09.14 |
RxJava를 활용한 페이징(Paging) (0) | 2017.09.13 |
RxJava1 -< 2로 올릴때 주의할 점 (0) | 2017.08.28 |
출처 : https://github.com/ReactiveX/RxAndroid/wiki
Broadcast
and LocalBroadcast
.RxJava Extection 라이버러리 (0) | 2017.09.15 |
---|---|
Rxjava를 활용한 두개의 리스트 항목 비교 (0) | 2017.09.14 |
RxJava를 활용한 페이징(Paging) (0) | 2017.09.13 |
RxJava1 -< 2로 올릴때 주의할 점 (0) | 2017.08.28 |
Observable과 Flowable을 언제 써야할까? (0) | 2017.08.25 |
/***
* This is a helper wrapper Subscriber that helps you lazily defer
* continuous paging of a result set from some API.
* Through the use of a {@link Subject}, it helps notify the original {@link Observable}
* when to perform an additional fetch.
* The notification is sent when a certain count of items has been reached.
* Generally this count represents the page.
* @param <T> The event type
*/
@Data
public class PagingSubscriber<T> extends Subscriber<T> {
private final Subject<Void,Void> nextPageTrigger = PublishSubject.create();
private final long pageSize;
private long count = 0;
private final Subscriber<T> delegate;
/***
* Creates the {@link PagingSubscriber}
* @param pageSize
* @param delegate
*/
public PagingSubscriber(long pageSize, Subscriber<T> delegate) {
this.pageSize = pageSize;
this.delegate = delegate;
}
public Observable<Void> getNextPageTrigger() {
return nextPageTrigger;
}
@Override
public void onStart() {
delegate.onStart();
}
@Override
public void onCompleted() {
delegate.onCompleted();
}
@Override
public void onError(Throwable e) {
delegate.onError(e);
}
@Override
public void onNext(T t) {
count+=1;
if (count == pageSize) {
nextPageTrigger.onNext(null);
count= 0;
}
delegate.onNext(t);
}
}
@Data
public class GitHubRepositoryApplication {
private final GitHubService gitHubService;
@Inject
public GitHubRepositoryApplication(GitHubService githubService) {
this.gitHubService = githubService;
}
public Observable<GitHubRepository> printAllRepositories(Observable<Void> nextPageTrigger) {
return printRepositoryPages(GitHubService.FIRST_PAGE, nextPageTrigger)
.flatMapIterable(r -> r.body());
}
public Observable<Response<List<GitHubRepository>>> printRepositoryPages(String startingPage, Observable<Void> nextPageTrigger) {
return gitHubService.listRepos(startingPage)
.concatMap(response -> {
Optional<String> nextPage = Optional.ofNullable(response.headers().get(HttpHeaders.LINK))
.flatMap(header -> GitHubServiceUtils.getNextToken(header));
if (!nextPage.isPresent()) {
return Observable.just(response);
}
return Observable.just(response)
.concatWith(nextPageTrigger.limit(1).ignoreElements().cast(Response.class))
.concatWith(printRepositoryPages(nextPage.get(), nextPageTrigger));
});
}
public static void main(String[] args) {
Injector injector = Guice.createInjector(new GitHubModule());
GitHubRepositoryApplication app = injector.getInstance(GitHubRepositoryApplication.class);
Subscriber<GitHubRepository> subscriber = new Subscriber<GitHubRepository>() {
private final Logger log = LoggerFactory.getLogger(getClass());
@Override
public void onStart() {
log.debug("STARTING");
request(1l);//we need to begin the request
}
@Override
public void onCompleted() {
log.debug("COMPLETED");
}
@Override
public void onError(Throwable e) {
log.error("ERROR",e);
}
@Override
public void onNext(GitHubRepository gitHubRepository) {
log.debug("{}",gitHubRepository);
request(1l);//we need to make sure we have asked for another element
}
};
PagingSubscriber<GitHubRepository> pagingSubscriber = new PagingSubscriber<>(GitHubService.PAGE_SIZE, subscriber);
//In order for the JVM not to quit out, we make sure we turn our Observable to
//a BlockingObservable, so that all of it will finish.
Observable<GitHubRepository> observable =
app.printAllRepositories(pagingSubscriber.getNextPageTrigger());
observable.toBlocking().subscribe(pagingSubscriber);
}
}
Rxjava를 활용한 두개의 리스트 항목 비교 (0) | 2017.09.14 |
---|---|
RxAndroid 활용한 라이버러리 모음 (0) | 2017.09.14 |
RxJava1 -< 2로 올릴때 주의할 점 (0) | 2017.08.28 |
Observable과 Flowable을 언제 써야할까? (0) | 2017.08.25 |
RxJava2.0 변경점 링크(번역본포함) (0) | 2017.08.24 |
안드로이드 디버깅 툴 총정리 (0) | 2017.09.27 |
---|---|
포토샵에서 이미지를 안드로이드 레이아웃 형식으로 넣기 (0) | 2017.09.14 |
TDD 흐름도 (0) | 2017.09.08 |
안드로이드 소스 모음 사이트 (0) | 2017.09.03 |
Mockito and PowerMockito 요약 (0) | 2017.09.02 |
포토샵에서 이미지를 안드로이드 레이아웃 형식으로 넣기 (0) | 2017.09.14 |
---|---|
Android , View component 설계 및 내용 (0) | 2017.09.12 |
안드로이드 소스 모음 사이트 (0) | 2017.09.03 |
Mockito and PowerMockito 요약 (0) | 2017.09.02 |
Dagger2 + Junit 테스트 (1) | 2017.09.02 |
아마존 직구방법 총정리 (0) | 2017.10.21 |
---|---|
데뷰 2017 자료 모음 (0) | 2017.10.20 |
무료 강의 (0) | 2017.09.02 |
Headless Chrome으로 AWS Lambda에서 웹사이트 스크린샷 찍기 링크구분 (0) | 2017.08.31 |
조직에서 원하는 인재상? (0) | 2017.08.23 |
꽤 괜찮은 것 많네요.
Android , View component 설계 및 내용 (0) | 2017.09.12 |
---|---|
TDD 흐름도 (0) | 2017.09.08 |
Mockito and PowerMockito 요약 (0) | 2017.09.02 |
Dagger2 + Junit 테스트 (1) | 2017.09.02 |
코틀린 dagger2 (0) | 2017.09.02 |
출처 : https://raseshmori.wordpress.com/2015/01/07/mockito-and-power-mockito-cheatsheet/
@RunWith(PowerMockRunner.class) – Tell Junit that run this test using PowerMockRunner
@PrepareForTest(A.class) – This is needed when we need to test static methods of A class
AService mock = PowerMockito.mock(A.class) – Creating a mock for A class
PowerMockito.when(mock.mockedMethod()).thenReturn(value) – When mockedMethod is called in the code, then return the value specified here.
PowerMockito.doNothing().when(mock).method() – do nothing when method() is called on mock object
Mockito.verify(mock).someMethod() – Verify that someMethod was called on mock once.
Mockito.verify(mock, times(n)).someMethod() – someMethod called n number of times
Mockito.verify(mock, never()).someMethod() – someMethod called n number of times
Mockito.verify(mock, atLeastOnce()).someMethod() – self explanatory
Mockito.verify(mock, atLeast(n)).someMethod() – self explanatory
Mockito.verify(mock, atMost(n)).someMethod() – self explanatory
Static
PowerMockito.mockStatic(A.class) – mock all static methods of class A
PowerMockito.doNothing().when(A.class)
A.staticMethod(value); – Nothing to be done when staticMethod(value) is called on class A
PowerMockito.doNothing().doThrow(new IllegalStateException()).when(A.class)
A.staticMethod(value); – Throw IllegalStateException when staticMethod(value) is called on class A
//We first have to inform PowerMock that we will now verify
//the invocation of a static method by calling verifyStatic.
PowerMockito.verifyStatic();
//Then we need to inform PowerMock about the method we want to verify.
//This is done by actually invoking the static
A.staticMethod();
@Before – annotation for a method that does the set up before starting the test.
InOrder verification
//First we have to let PowerMock know that the verification order is
//going to be important. This is done by calling Mockito.inOrder and passing
//it the mocked object.
InOrder inOrder = Mockito.inOrder(mock);
//Next, we can continue our verification using the inOrder instance
//using the same technique as seen earlier.
inOrder.verify(mock).isNew();
inOrder.verify(mock).update();
inOrder.verify(mock, Mockito.never()).create();
Constructor
PowerMockito.whenNew(A.class).withArguments(mock, “msg”).thenReturn(object)
PowerMockito.verifyNew(A.class).withArguments(mock, “msg”)
PowerMockito.verifyNew(A.class, times(n)).withArguments(mock, “msg”)
The class creating an object of A will be needed to be in @PrepareForTest
Matchers
PowerMockito.when(mock.method(Mockito.startsWith(“somestring”))).thenReturn(objValue);
Assert.assertSame(objValue, mock.method(“somestring123”));
Assert.assertSame(objValue, mock.method(“somestring456”));
PowerMockito.when(mock.method(Mockito.argThat(new ArgumentMatcher){public void matches(Object obj)….}).thenReturn(value); – Use the custom matcher to match the argument and return the value specified.
Mockito.eq(value)
Mockito.matches(regex)
Mockito.anyString, anyFloat, anyDouble, anyList, and so on
Mockito.isNull
Mockito.isNotNull
Mockito.isA
Mockito.endsWith
Answer Interface
When thenReturn() is not practical, use Answer interface
PowerMockito.when(mock.method()).then(new Answer<T>() {
public T answer(InvocationOnMock invocation) {
…invocation.getArguments()….
}
});
PowerMockito.mock(A.class, Answer obj) – This will act as default answer for all the invocation on this mock object.
Spy – Partial Mocking (some methods) of classes
//Following is the syntax to create a spy using the PowerMockito.spy method.
//Notice that we have to pass an actual instance of the EmployeeService class.
//This is necessary since a spy will only mock few methods of a class and
//invoke the real methods for all methods that are not mocked.
final EmployeeService spy = PowerMockito.spy(new EmployeeService());
//Notice that we have to use the PowerMockito.doNothing().when(spy).createEmployee()
//syntax to create the spy. This is required because if we use the
//PowerMockito.when(spy.createEmployee()) syntax will result in calling
//the actual method on the spy.
//Hence, remember when we are using spies,
//always use the doNothing(), doReturn() or the //doThrow() syntax only. PowerMockito.doNothing().when(spy)
.createEmployee(employeeMock);
Mocking private methods
PowerMockito.doNothing().when(spy,
“createEmployee”, employeeMock);
PowerMockito.verifyPrivate(spy)
.invoke(“createEmployee”, employeeMock);
TDD 흐름도 (0) | 2017.09.08 |
---|---|
안드로이드 소스 모음 사이트 (0) | 2017.09.03 |
Dagger2 + Junit 테스트 (1) | 2017.09.02 |
코틀린 dagger2 (0) | 2017.09.02 |
Android Junit 테스트 링크 모음 (0) | 2017.09.01 |
데뷰 2017 자료 모음 (0) | 2017.10.20 |
---|---|
파일별 시그니처 확인법 (0) | 2017.09.05 |
Headless Chrome으로 AWS Lambda에서 웹사이트 스크린샷 찍기 링크구분 (0) | 2017.08.31 |
조직에서 원하는 인재상? (0) | 2017.08.23 |
권한설정 법 (0) | 2017.08.21 |
안드로이드 소스 모음 사이트 (0) | 2017.09.03 |
---|---|
Mockito and PowerMockito 요약 (0) | 2017.09.02 |
코틀린 dagger2 (0) | 2017.09.02 |
Android Junit 테스트 링크 모음 (0) | 2017.09.01 |
Android Junit MVP + RxJava (0) | 2017.09.01 |
코틀린 Junit test
https://proandroiddev.com/using-kotlin-for-tests-in-android-6d4a0c818776
핵심은
sourceSets {
test.java.srcDirs += 'src/test/kotlin'
}
}
afterEvaluate {
android.sourceSets.all { sourceSet ->
if (!sourceSet.name.startsWith("test"))
{
sourceSet.kotlin.setSrcDirs([])
}
}
}
으로 해서 릴리즈땐 제거 해주고
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_ver"
을 추가 해주는게 핵심..
RxKotlin 으로 로그인 화면 유효성체크해보기 (0) | 2017.11.18 |
---|---|
kotlin-let-apply-run-with-use 사용방법 (0) | 2017.11.17 |
코틀린 1.1 한글번역 문서 (0) | 2017.11.02 |
코틀린 가이드 깃북 (0) | 2017.09.02 |
코틀린 DI 주입시..꼭 고려해야할 내용 (0) | 2017.09.02 |
RxKotlin 으로 로그인 화면 유효성체크해보기 (0) | 2017.11.18 |
---|---|
kotlin-let-apply-run-with-use 사용방법 (0) | 2017.11.17 |
코틀린 1.1 한글번역 문서 (0) | 2017.11.02 |
코틀린 Junit 사용하기 (0) | 2017.09.02 |
코틀린 DI 주입시..꼭 고려해야할 내용 (0) | 2017.09.02 |