@Test
public void testAddSameObserverIn2LifecycleOwners() {

    Observer<String> observer = (Observer<String>) mock(Observer.class);
    LifecycleOwner owner2 = mock(LifecycleOwner.class);
    LifecycleRegistry registry2 = new LifecycleRegistry(owner2);
    when(owner2.getLifecycle()).thenReturn(registry2);
    mLiveData.observe(mOwner, observer);
    Throwable throwable = null;
    try {
        mLiveData.observe(owner2, observer);
    } catch (Throwable t) {
        throwable = t;
    }
    assertThat(throwable, instanceOf(IllegalArgumentException.class));
    //noinspection ConstantConditions
    assertThat(throwable.getMessage(),
            is("Cannot add the same observer with different lifecycles"));
}