/*
 * Copyright (C) 2016 Mobile Jazz
 *
 *  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 com.mobilejazz.cacheio;

import android.content.Context;
import com.mobilejazz.cacheio.logging.LogLevel;
import com.mobilejazz.cacheio.serializer.JavaSerializer;
import com.mobilejazz.cacheio.serializer.Serializer;
import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.mock;

public class CacheIOTest extends ApplicationTestCase {

  public static final String FAKE_IDENTIFIER = "fake.identifier";
  private Context context;

  private Serializer serializer;

  @Before public void setUp() throws Exception {
    context = mock(Context.class);
    serializer = mock(JavaSerializer.class);
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldThrowExceptionIfSerializerIsNull() throws Exception {
    CacheIO cacheIO = CacheIO.with(context)
        .identifier(FAKE_IDENTIFIER)
        .logLevel(LogLevel.FULL)
        .serializer(null)
        .build();
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldThrowExceptionIfIdentifierIsNull() throws Exception {
    CacheIO cacheIO = CacheIO.with(context)
        .identifier(null)
        .logLevel(LogLevel.FULL)
        .serializer(serializer)
        .build();
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldThrowExceptionIfIdentifierIsEmpty() throws Exception {
    CacheIO cacheIO =
        CacheIO.with(context).identifier("").logLevel(LogLevel.FULL).serializer(serializer).build();
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldThrowExceptionIfLogLevelIsNull() throws Exception {
    CacheIO cacheIO = CacheIO.with(context)
        .identifier(FAKE_IDENTIFIER)
        .logLevel(null)
        .serializer(serializer)
        .build();
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldThrowExceptionIfContextIsNull() throws Exception {
    CacheIO cacheIO = CacheIO.with(null)
        .identifier(FAKE_IDENTIFIER)
        .logLevel(LogLevel.FULL)
        .serializer(serializer)
        .build();
  }
}

@@ -824,24 +824,64 @@
 Serializer;%0A
+import org.assertj.core.api.Assertions;%0A
 import org.j
@@ -2670,11 +2670,344 @@
 d();%0A  %7D
+%0A%0A  @Test public void shouldCreateAValidCacheObject() throws Exception %7B%0A    CacheIO cacheIO = CacheIO.with(context)%0A        .identifier(FAKE_IDENTIFIER)%0A        .logLevel(LogLevel.FULL)%0A        .serializer(serializer)%0A        .build();%0A%0A    Cache cache = cacheIO.cacheDataSource();%0A%0A    Assertions.assertThat(cache).isNotNull();%0A  %7D
 %0A%7D%0A

Check if the cacheDataSource method generate a proper instance of Cache class