'링크모음 > 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

https://httpbin.org/

'링크모음' 카테고리의 다른 글

mysql 속도 개선  (0) 2018.07.02
http://blackturtle.tistory.com/m/711821

{ [weak self] offset in

        guard let `self` = self else { return false } //<-- 체크..

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

'링크모음 > Swift' 카테고리의 다른 글

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

'링크모음 > rxswift' 카테고리의 다른 글

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;
}


'링크모음 > java' 카테고리의 다른 글

java9 빠르게 핵심만  (0) 2017.11.07
대표적인 소프트웨어 아키텍쳐 10가지  (0) 2017.09.15
DTO와 VO 차이점..  (0) 2017.08.09
출처: http://doohyun.tistory.com/44 [N`s Lab]


List<SubjectRelation> subjectRelationList = Arrays.asList(
                    new SubjectRelation(11001"Doohyun Nam"1)
                    , new SubjectRelation(11002"Dolkin"2)
                    , new SubjectRelation(11003"hshawng"1)
                    , new SubjectRelation(11004"spKwon"1)
                    , new SubjectRelation(21005"Other Person1"3)
                    , new SubjectRelation(21006"Other Person2"4)
            );
 
// create Map
Map<Integer, Collection<String>> mapTest = Observable.fromIterable(subjectRelationList).
           toMultimap(SubjectRelation::getCompanySubjectSn, SubjectRelation::getMemberName).
           blockingGet();
 
 
// only subscribe
Observable.fromIterable(subjectRelationList)
            .groupBy(SubjectRelation::getCompanySubjectSn).subscribe(group -> {
                  System.out.println(group.getKey());
                group.map(SubjectRelation::getMemberName).forEach(System.out::println);
            });
 
// create multi group
 Map<Integer, Map<Integer, Collection<String>>> doubleKeyMap = new HashMap<>();
            Observable.fromIterable(subjectRelationList).
                    groupBy(SubjectRelation::getCompanySubjectSn).
                    blockingSubscribe(group ->
                        doubleKeyMap.put(group.getKey(),
                                group.toMultimap(
                                        SubjectRelation::getOrganizationSubjectSn
                                        , SubjectRelation::getMemberName).blockingGet())
                    );
 
// partitioning
Map<Boolean, Collection<String>> partitioningMap = Observable.fromIterable(subjectRelationList).
             toMultimap(subjectRelation -> subjectRelation.getCompanySubjectSn().intValue() == 1
                 , SubjectRelation::getMemberName).
             blockingGet();



'링크모음 > java' 카테고리의 다른 글

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

포토샵에서 스크립트로 다 분리하는 방법입니다.


http://www.uncorkedstudios.com/blog/export-to-android-photoshop-script/


'링크모음 > Android' 카테고리의 다른 글

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);
    }
});


'링크모음 > rxjava' 카테고리의 다른 글

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


  • RxLifecycle - Lifecycle handling APIs for Android apps using RxJava
  • RxBinding - RxJava binding APIs for Android's UI widgets.
  • SqlBrite - A lightweight wrapper around SQLiteOpenHelper and ContentResolver which introduces reactive stream semantics to queries.
  • Android-ReactiveLocation - Library that wraps location play services API boilerplate with a reactive friendly API. (RxJava 1)
  • RxLocation - Reactive Location APIs Library for Android. (RxJava 2)
  • rx-preferences - Reactive SharedPreferences for Android
  • RxFit - Reactive Fitness API Library for Android
  • RxWear - Reactive Wearable API Library for Android
  • RxPermissions - Android runtime permissions powered by RxJava
  • RxNotification - Easy way to register, remove and manage notifications using RxJava
  • RxClipboard - RxJava binding APIs for Android clipboard.
  • RxBroadcast - RxJava bindings for Broadcast and LocalBroadcast.
  • RxAndroidBle - Reactive library for handling Bluetooth LE devices.
  • RxImagePicker - Reactive library for selecting images from gallery or camera.
  • ReactiveNetwork - Reactive library listening network connection state and Internet connectivity (compatible with RxJava1.x and RxJava2.x)
  • ReactiveBeacons - Reactive library scanning BLE (Bluetooth Low Energy) beacons nearby (compatible with RxJava1.x and RxJava2.x)
  • ReactiveAirplaneMode - Reactive library listening airplane mode (compatible with RxJava2.x)
  • RxDataBinding - RxJava2 binding APIs for Android's Data Binding Library.
  • RxLocationManager - RxJava/RxJava2 wrap around standard Android LocationManager without Google Play Services.


/***
 * 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);

    }

}


http://forensic-proof.com/archives/300

꽤 괜찮은 것 많네요.

http://download.androidhive.info/

'링크모음 > Android' 카테고리의 다른 글

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);

'링크모음 > Android' 카테고리의 다른 글

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
https://okky.kr/article/413054?utm_referrer=https%3A%2F%2Fzen.yandex.com

'링크모음 > Android' 카테고리의 다른 글

안드로이드 소스 모음 사이트  (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"


을 추가 해주는게 핵심..

+ Recent posts