// Path: storebox-lib/src/main/java/net/orange_box/storebox/StoreBox.java
// public final class StoreBox {
// 
//     /**
//      * @param context - the context under which the
//      * {@link android.content.SharedPreferences} should be opened
//      * @param cls - the interface class which should be instantiated
//      * @return new instance of class {@code cls} using {@code context}
//      */
//     public static <T> T create(Context context, Class<T> cls) {
//         return new Builder<>(context, cls).build();
//     }
// 
//     private StoreBox() {}
// 
//     /**
//      * Can be used to provide a customised instance of the supplied interface,
//      * by setting custom options through builder methods.
//      * 
//      * @param <T>
//      */
//     public static final class Builder<T> {
// 
//         private final Context context;
//         private final Class<T> cls;
// 
//         private PreferencesType preferencesType = PreferencesType.DEFAULT_SHARED;
//         private String preferencesName = "";
//         private PreferencesMode preferencesMode = PreferencesMode.MODE_PRIVATE;
//         private SaveMode saveMode = SaveMode.APPLY;
// 
//         public Builder(Context context, Class<T> cls) {
//             this.context = context;
//             this.cls = cls;
//             
//             readAnnotations();
//         }
// 
//         public Builder preferencesType(PreferencesType value) {
//             preferencesType = value;
//             return this;
//         }
// 
//         public Builder preferencesType(
//                 PreferencesType value, String name) {
// 
//             preferencesType = value;
//             preferencesName = name;
//             return this;
//         }
// 
//         public Builder preferencesMode(PreferencesMode value) {
//             preferencesMode = value;
//             return this;
//         }
// 
//         public Builder saveMode(SaveMode value) {
//             saveMode = value;
//             return this;
//         }
// 
//         /**
//          * @return new instance of class {@code cls} using {@code context}
//          */
//         @SuppressWarnings("unchecked")
//         public T build() {
//             validate();
//             
//             return (T) Proxy.newProxyInstance(
//                     cls.getClassLoader(),
//                     new Class[]{cls},
//                     new StoreBoxInvocationHandler(
//                             context,
//                             preferencesType,
//                             preferencesName,
//                             preferencesMode,
//                             saveMode));
//         }
//         
//         private void readAnnotations() {
//             // type/mode option
//             if (cls.isAnnotationPresent(DefaultSharedPreferences.class)) {
//                 preferencesType(PreferencesType.DEFAULT_SHARED);
//             } else if (cls.isAnnotationPresent(ActivityPreferences.class)) {
//                 final ActivityPreferences annotation =
//                         cls.getAnnotation(ActivityPreferences.class);
// 
//                 preferencesType(PreferencesType.ACTIVITY);
//                 preferencesMode(annotation.mode());
//             } else if (cls.isAnnotationPresent(FilePreferences.class)) {
//                 final FilePreferences annotation =
//                         cls.getAnnotation(FilePreferences.class);
// 
//                 preferencesType(PreferencesType.FILE, annotation.value());
//                 preferencesMode(annotation.mode());
//             }
//             // save option 
//             if (cls.isAnnotationPresent(SaveOption.class)) {
//                 saveMode(cls.getAnnotation(SaveOption.class).value());
//             }
//         }
//         
//         private void validate() {
//             if (context == null) {
//                 throw new IllegalArgumentException(
//                         "Context cannot be null");
//             }
//             if (cls == null) {
//                 throw new IllegalArgumentException(
//                         "Class cannot be null");
//             } else if (!cls.isInterface()) {
//                 throw new IllegalArgumentException(
//                         "Class needs to be an interface");
//             }
//             
//             if (preferencesType == PreferencesType.ACTIVITY) {
//                 if (!(context instanceof Activity)) {
//                     throw new IllegalArgumentException(String.format(
//                             Locale.ENGLISH,
//                             "Cannot use %1$s without an Activity context",
//                             PreferencesType.ACTIVITY.name()));
//                 }
//             } else if (preferencesType == PreferencesType.FILE) {
//                 if (TextUtils.isEmpty(preferencesName)) {
//                     throw new IllegalArgumentException(String.format(
//                             Locale.ENGLISH,
//                             "Cannot use %1$s with an empty file name",
//                             PreferencesType.FILE.name()));
//                 }
//             }
//         }
//     }
// }
// 
// Path: storebox-harness/src/main/java/net/orange_box/storebox/harness/interfaces/ChainingMethodsInterface.java
// public interface ChainingMethodsInterface {
//     
//     @KeyByString("first")
//     SharedPreferences.Editor setFirstValue(String value);
// 
//     @KeyByString("second")
//     ChainingMethodsInterface setSecondValue(String value);
// 
//     @KeyByString("first")
//     @RemoveMethod
//     SharedPreferences.Editor removeFirstValue();
// 
//     @KeyByString("second")
//     @RemoveMethod
//     ChainingMethodsInterface removeSecondValue();
// }


import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import net.orange_box.storebox.StoreBox;
import net.orange_box.storebox.harness.interfaces.ChainingMethodsInterface;
/*
 * Copyright 2015 Martin Bella
 * 
 * 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 net.orange_box.storebox.harness;



public class ChainingMethodsTestCase extends InstrumentationTestCase {

    private ChainingMethodsInterface uut;
    private SharedPreferences prefs;
    
    @Override
    protected void setUp() throws Exception {
        super.setUp();

        uut = StoreBox.create(
                getInstrumentation().getTargetContext(),
// Path: storebox-lib/src/main/java/net/orange_box/storebox/StoreBox.java
// public final class StoreBox {
// 
//     /**
//      * @param context - the context under which the
//      * {@link android.content.SharedPreferences} should be opened
//      * @param cls - the interface class which should be instantiated
//      * @return new instance of class {@code cls} using {@code context}
//      */
//     public static <T> T create(Context context, Class<T> cls) {
//         return new Builder<>(context, cls).build();
//     }
// 
//     private StoreBox() {}
// 
//     /**
//      * Can be used to provide a customised instance of the supplied interface,
//      * by setting custom options through builder methods.
//      * 
//      * @param <T>
//      */
//     public static final class Builder<T> {
// 
//         private final Context context;
//         private final Class<T> cls;
// 
//         private PreferencesType preferencesType = PreferencesType.DEFAULT_SHARED;
//         private String preferencesName = "";
//         private PreferencesMode preferencesMode = PreferencesMode.MODE_PRIVATE;
//         private SaveMode saveMode = SaveMode.APPLY;
// 
//         public Builder(Context context, Class<T> cls) {
//             this.context = context;
//             this.cls = cls;
//             
//             readAnnotations();
//         }
// 
//         public Builder preferencesType(PreferencesType value) {
//             preferencesType = value;
//             return this;
//         }
// 
//         public Builder preferencesType(
//                 PreferencesType value, String name) {
// 
//             preferencesType = value;
//             preferencesName = name;
//             return this;
//         }
// 
//         public Builder preferencesMode(PreferencesMode value) {
//             preferencesMode = value;
//             return this;
//         }
// 
//         public Builder saveMode(SaveMode value) {
//             saveMode = value;
//             return this;
//         }
// 
//         /**
//          * @return new instance of class {@code cls} using {@code context}
//          */
//         @SuppressWarnings("unchecked")
//         public T build() {
//             validate();
//             
//             return (T) Proxy.newProxyInstance(
//                     cls.getClassLoader(),
//                     new Class[]{cls},
//                     new StoreBoxInvocationHandler(
//                             context,
//                             preferencesType,
//                             preferencesName,
//                             preferencesMode,
//                             saveMode));
//         }
//         
//         private void readAnnotations() {
//             // type/mode option
//             if (cls.isAnnotationPresent(DefaultSharedPreferences.class)) {
//                 preferencesType(PreferencesType.DEFAULT_SHARED);
//             } else if (cls.isAnnotationPresent(ActivityPreferences.class)) {
//                 final ActivityPreferences annotation =
//                         cls.getAnnotation(ActivityPreferences.class);
// 
//                 preferencesType(PreferencesType.ACTIVITY);
//                 preferencesMode(annotation.mode());
//             } else if (cls.isAnnotationPresent(FilePreferences.class)) {
//                 final FilePreferences annotation =
//                         cls.getAnnotation(FilePreferences.class);
// 
//                 preferencesType(PreferencesType.FILE, annotation.value());
//                 preferencesMode(annotation.mode());
//             }
//             // save option 
//             if (cls.isAnnotationPresent(SaveOption.class)) {
//                 saveMode(cls.getAnnotation(SaveOption.class).value());
//             }
//         }
//         
//         private void validate() {
//             if (context == null) {
//                 throw new IllegalArgumentException(
//                         "Context cannot be null");
//             }
//             if (cls == null) {
//                 throw new IllegalArgumentException(
//                         "Class cannot be null");
//             } else if (!cls.isInterface()) {
//                 throw new IllegalArgumentException(
//                         "Class needs to be an interface");
//             }
//             
//             if (preferencesType == PreferencesType.ACTIVITY) {
//                 if (!(context instanceof Activity)) {
//                     throw new IllegalArgumentException(String.format(
//                             Locale.ENGLISH,
//                             "Cannot use %1$s without an Activity context",
//                             PreferencesType.ACTIVITY.name()));
//                 }
//             } else if (preferencesType == PreferencesType.FILE) {
//                 if (TextUtils.isEmpty(preferencesName)) {
//                     throw new IllegalArgumentException(String.format(
//                             Locale.ENGLISH,
//                             "Cannot use %1$s with an empty file name",
//                             PreferencesType.FILE.name()));
//                 }
//             }
//         }
//     }
// }
// 
// Path: storebox-harness/src/main/java/net/orange_box/storebox/harness/interfaces/ChainingMethodsInterface.java
// public interface ChainingMethodsInterface {
//     
//     @KeyByString("first")
//     SharedPreferences.Editor setFirstValue(String value);
// 
//     @KeyByString("second")
//     ChainingMethodsInterface setSecondValue(String value);
// 
//     @KeyByString("first")
//     @RemoveMethod
//     SharedPreferences.Editor removeFirstValue();
// 
//     @KeyByString("second")
//     @RemoveMethod
//     ChainingMethodsInterface removeSecondValue();
// }


// Path: storebox-harness/src/androidTest/java/net/orange_box/storebox/harness/ChainingMethodsTestCase.java
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import net.orange_box.storebox.StoreBox;
import net.orange_box.storebox.harness.interfaces.ChainingMethodsInterface;

/*
 * Copyright 2015 Martin Bella
 * 
 * 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 net.orange_box.storebox.harness;



public class ChainingMethodsTestCase extends InstrumentationTestCase {

    private ChainingMethodsInterface uut;
    private SharedPreferences prefs;
    
    @Override
    protected void setUp() throws Exception {
        super.setUp();

        uut = StoreBox.create(
                getInstrumentation().getTargetContext(),
                ChainingMethodsInterface.class);