// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/data/exception/DataNotFoundException.java
// public class DataNotFoundException extends Exception {
// 
// }
// 
// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/data/model/Task.java
// public class Task {
// 
//   private boolean mCompleted;
// 
//   private String mDescription;
// 
//   private String mId;
// 
//   private String mTitle;
// 
//   public Task(String id, String title, String description) {
//     mId = id;
//     mTitle = title;
//     mDescription = description;
//   }
// 
//   protected Task(String id, String title, String description, boolean completed) {
//     mId = id;
//     mTitle = title;
//     mDescription = description;
//     mCompleted = completed;
//   }
// 
//   public Task(String title, String description) {
//     this(UUID.randomUUID().toString(), title, description);
//   }
// 
//   @Override
//   public int hashCode() {
//     return Objects.hashCode(mId, mTitle, mDescription, mCompleted);
//   }
// 
//   public void active() {
//     mCompleted = false;
//   }
// 
//   public void complete() {
//     mCompleted = true;
//   }
// 
//   public String getDescription() {
//     return mDescription;
//   }
// 
//   public void setDescription(String description) {
//     mDescription = description;
//   }
// 
//   public String getId() {
//     return mId;
//   }
// 
//   public String getTitle() {
//     return mTitle;
//   }
// 
//   public void setTitle(String title) {
//     mTitle = title;
//   }
// 
//   public boolean isActive() {
//     return !isCompleted();
//   }
// 
//   public boolean isCompleted() {
//     return mCompleted;
//   }
// 
//   public void setCompleted(boolean completed) {
//     mCompleted = completed;
//   }
// }
// 
// Path: sample/src/test/java/me/henrytao/mvvmlifecycledemo/util/BaseTest.java
// public class BaseTest {
// 
//   @Before
//   public void initialize() {
//     MockitoAnnotations.initMocks(this);
//     Transformer.overrideComputationScheduler(Schedulers.immediate());
//     Transformer.overrideIoScheduler(Schedulers.immediate());
//     Transformer.overrideMainThreadScheduler(Schedulers.immediate());
//     Transformer.overrideNewThreadScheduler(Schedulers.immediate());
//   }
// 
//   @After
//   public void release() {
//     Transformer.resetComputationScheduler();
//     Transformer.resetIoScheduler();
//     Transformer.resetMainThreadScheduler();
//     Transformer.resetNewThreadScheduler();
//   }
// }


import org.junit.Test;
import me.henrytao.mvvmlifecycledemo.data.exception.DataNotFoundException;
import me.henrytao.mvvmlifecycledemo.data.model.Task;
import me.henrytao.mvvmlifecycledemo.util.BaseTest;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
/*
 * Copyright 2016 "Henry Tao <hi@henrytao.me>"
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.henrytao.mvvmlifecycledemo.data.adapter.local;




/**
 * Created by henrytao on 4/22/16.
 */
public class LocalAdapterTest extends BaseTest {

  private LocalAdapter mLocalAdapter;

  @Override
  public void initialize() {
    super.initialize();
    mLocalAdapter = spy(new LocalAdapter());
  }

  @Test(expected = DataNotFoundException.class)
  public void testActiveTaskError() throws Exception {
    doReturn(null).when(mLocalAdapter).findTask(any());

    mLocalAdapter.activeTask("taskId");
  }

  @Test
  public void testActiveTaskSuccess() throws Exception {
// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/data/exception/DataNotFoundException.java
// public class DataNotFoundException extends Exception {
// 
// }
// 
// Path: sample/src/main/java/me/henrytao/mvvmlifecycledemo/data/model/Task.java
// public class Task {
// 
//   private boolean mCompleted;
// 
//   private String mDescription;
// 
//   private String mId;
// 
//   private String mTitle;
// 
//   public Task(String id, String title, String description) {
//     mId = id;
//     mTitle = title;
//     mDescription = description;
//   }
// 
//   protected Task(String id, String title, String description, boolean completed) {
//     mId = id;
//     mTitle = title;
//     mDescription = description;
//     mCompleted = completed;
//   }
// 
//   public Task(String title, String description) {
//     this(UUID.randomUUID().toString(), title, description);
//   }
// 
//   @Override
//   public int hashCode() {
//     return Objects.hashCode(mId, mTitle, mDescription, mCompleted);
//   }
// 
//   public void active() {
//     mCompleted = false;
//   }
// 
//   public void complete() {
//     mCompleted = true;
//   }
// 
//   public String getDescription() {
//     return mDescription;
//   }
// 
//   public void setDescription(String description) {
//     mDescription = description;
//   }
// 
//   public String getId() {
//     return mId;
//   }
// 
//   public String getTitle() {
//     return mTitle;
//   }
// 
//   public void setTitle(String title) {
//     mTitle = title;
//   }
// 
//   public boolean isActive() {
//     return !isCompleted();
//   }
// 
//   public boolean isCompleted() {
//     return mCompleted;
//   }
// 
//   public void setCompleted(boolean completed) {
//     mCompleted = completed;
//   }
// }
// 
// Path: sample/src/test/java/me/henrytao/mvvmlifecycledemo/util/BaseTest.java
// public class BaseTest {
// 
//   @Before
//   public void initialize() {
//     MockitoAnnotations.initMocks(this);
//     Transformer.overrideComputationScheduler(Schedulers.immediate());
//     Transformer.overrideIoScheduler(Schedulers.immediate());
//     Transformer.overrideMainThreadScheduler(Schedulers.immediate());
//     Transformer.overrideNewThreadScheduler(Schedulers.immediate());
//   }
// 
//   @After
//   public void release() {
//     Transformer.resetComputationScheduler();
//     Transformer.resetIoScheduler();
//     Transformer.resetMainThreadScheduler();
//     Transformer.resetNewThreadScheduler();
//   }
// }


// Path: sample/src/test/java/me/henrytao/mvvmlifecycledemo/data/adapter/local/LocalAdapterTest.java
import org.junit.Test;
import me.henrytao.mvvmlifecycledemo.data.exception.DataNotFoundException;
import me.henrytao.mvvmlifecycledemo.data.model.Task;
import me.henrytao.mvvmlifecycledemo.util.BaseTest;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

/*
 * Copyright 2016 "Henry Tao <hi@henrytao.me>"
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.henrytao.mvvmlifecycledemo.data.adapter.local;




/**
 * Created by henrytao on 4/22/16.
 */
public class LocalAdapterTest extends BaseTest {

  private LocalAdapter mLocalAdapter;

  @Override
  public void initialize() {
    super.initialize();
    mLocalAdapter = spy(new LocalAdapter());
  }

  @Test(expected = DataNotFoundException.class)
  public void testActiveTaskError() throws Exception {
    doReturn(null).when(mLocalAdapter).findTask(any());

    mLocalAdapter.activeTask("taskId");
  }

  @Test
  public void testActiveTaskSuccess() throws Exception {
    Task task = new Task("title", "description");