// Path: api/src/main/java/com/ebuddy/cassandra/Path.java
// public interface Path {
// 
//     /** Return a new Path consisting of this Path concatenated with another Path. */
//     Path concat(Path other);
// 
//     /** Return a new Path consisting of this Path concatenated with the specified list indices as elements. */
//     Path withIndices(int... indices);
// 
//     /** Return a new Path consisting of this Path concatenated with the specified elements. */
//     Path withElements(String... elements);
// 
//     /** Get the encoded elements of this Path. */
//     Iterable<String> getElements();
// 
//     /**
//      * Returns the first element in this path, or null if this is an empty path.
//      */
//     String head();
// 
//     /**
//      * Returns the rest of the path after the head (first) element.
//      * If this is an empty path, throws IndexOutOfBoundsException,
//      * if this path has only one element, return an empty path,
//      * otherwise return a new path with elements starting after the head.
//      */
//     Path tail();
// 
//     /**
//      * Return a new Path consisting of the rest of the path elements of this path starting with the specified index.
//      * @param startIndex 0-based start index
//      * @return new Path
//      * @throws IndexOutOfBoundsException if path has insufficient size
//      */
//     Path tail(int startIndex);
// 
//     /**
//      * Return true if this path starts with the specified path.
//      */
//     boolean startsWith(Path path);
// 
//     /** Get the number of elements in this path. */
//     int size();
// 
//     /** Return true if this Path has zero elements. */
//     boolean isEmpty();
// }
// 
// Path: api/src/main/java/com/ebuddy/cassandra/TypeReference.java
// public abstract class TypeReference<T>
//         implements Comparable<TypeReference<T>>
// {
//     protected final Type type;
// 
//     protected TypeReference()
//     {
//         Type superClass = getClass().getGenericSuperclass();
//         if (superClass instanceof Class<?>) { // sanity check, should never happen
//             throw new IllegalArgumentException("Internal error: TypeReference constructed without actual type information");
//         }
//         /* 22-Dec-2008, tatu: Not sure if this case is safe -- I suspect
//          *   it is possible to make it fail?
//          *   But let's deal with specific
//          *   case when we know an actual use case, and thereby suitable
//          *   workarounds for valid case(s) and/or error to throw
//          *   on invalid one(s).
//          */
//         type = ((ParameterizedType) superClass).getActualTypeArguments()[0];
//     }
// 
//     public Type getType() { return type; }
// 
//     /**
//      * The only reason we define this method (and require implementation
//      * of {@code Comparable}) is to prevent constructing a
//      * reference without type information.
//      */
//     @Override
//     public int compareTo(TypeReference<T> o) {
//         // just need an implementation, not a good one... hence:
//         return 0;
//     }
// }


import org.testng.annotations.Test;
import com.ebuddy.cassandra.Path;
import com.ebuddy.cassandra.TypeReference;
import static org.apache.commons.lang3.ObjectUtils.NULL;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeMethod;
/*
 * Copyright 2013 eBuddy B.V.
 *
 *    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.ebuddy.cassandra.dao;





/**
 * Unit tests for ThriftStructuredDataSupport.
 *
 * @author Eric Zoerner <a href="mailto:ezoerner@ebuddy.com">ezoerner@ebuddy.com</a>
 */
public class ThriftStructuredDataSupportTest {
    private static final int MAX_CODE_POINT = 0x10FFFF;

    @Mock
    private ColumnFamilyOperations<String,String,Object> operations;

    private ThriftStructuredDataSupport<String> dao ;
    private final String rowKey = "rowKey";
    private final TypeReference<TestPojo> typeReference = new TypeReference<TestPojo>() { };
    private Path path;

    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        dao = new ThriftStructuredDataSupport<String>(operations);
        path = dao.createPath("a","b","c");
    }

    @Test(groups = {"unit"})
    public void shouldReadFromPath() throws Exception {

        Map<String,Object> stringObjectMap = getExpectedMap(false);

        when(operations.readColumnsAsMap(rowKey,
                                         "a/b/c/",
                                         getFinishString("a/b/c/"),
                                         Integer.MAX_VALUE,
// Path: api/src/main/java/com/ebuddy/cassandra/Path.java
// public interface Path {
// 
//     /** Return a new Path consisting of this Path concatenated with another Path. */
//     Path concat(Path other);
// 
//     /** Return a new Path consisting of this Path concatenated with the specified list indices as elements. */
//     Path withIndices(int... indices);
// 
//     /** Return a new Path consisting of this Path concatenated with the specified elements. */
//     Path withElements(String... elements);
// 
//     /** Get the encoded elements of this Path. */
//     Iterable<String> getElements();
// 
//     /**
//      * Returns the first element in this path, or null if this is an empty path.
//      */
//     String head();
// 
//     /**
//      * Returns the rest of the path after the head (first) element.
//      * If this is an empty path, throws IndexOutOfBoundsException,
//      * if this path has only one element, return an empty path,
//      * otherwise return a new path with elements starting after the head.
//      */
//     Path tail();
// 
//     /**
//      * Return a new Path consisting of the rest of the path elements of this path starting with the specified index.
//      * @param startIndex 0-based start index
//      * @return new Path
//      * @throws IndexOutOfBoundsException if path has insufficient size
//      */
//     Path tail(int startIndex);
// 
//     /**
//      * Return true if this path starts with the specified path.
//      */
//     boolean startsWith(Path path);
// 
//     /** Get the number of elements in this path. */
//     int size();
// 
//     /** Return true if this Path has zero elements. */
//     boolean isEmpty();
// }
// 
// Path: api/src/main/java/com/ebuddy/cassandra/TypeReference.java
// public abstract class TypeReference<T>
//         implements Comparable<TypeReference<T>>
// {
//     protected final Type type;
// 
//     protected TypeReference()
//     {
//         Type superClass = getClass().getGenericSuperclass();
//         if (superClass instanceof Class<?>) { // sanity check, should never happen
//             throw new IllegalArgumentException("Internal error: TypeReference constructed without actual type information");
//         }
//         /* 22-Dec-2008, tatu: Not sure if this case is safe -- I suspect
//          *   it is possible to make it fail?
//          *   But let's deal with specific
//          *   case when we know an actual use case, and thereby suitable
//          *   workarounds for valid case(s) and/or error to throw
//          *   on invalid one(s).
//          */
//         type = ((ParameterizedType) superClass).getActualTypeArguments()[0];
//     }
// 
//     public Type getType() { return type; }
// 
//     /**
//      * The only reason we define this method (and require implementation
//      * of {@code Comparable}) is to prevent constructing a
//      * reference without type information.
//      */
//     @Override
//     public int compareTo(TypeReference<T> o) {
//         // just need an implementation, not a good one... hence:
//         return 0;
//     }
// }


// Path: thrift/src/test/java/com/ebuddy/cassandra/dao/ThriftStructuredDataSupportTest.java
import org.testng.annotations.Test;
import com.ebuddy.cassandra.Path;
import com.ebuddy.cassandra.TypeReference;
import static org.apache.commons.lang3.ObjectUtils.NULL;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeMethod;

/*
 * Copyright 2013 eBuddy B.V.
 *
 *    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.ebuddy.cassandra.dao;





/**
 * Unit tests for ThriftStructuredDataSupport.
 *
 * @author Eric Zoerner <a href="mailto:ezoerner@ebuddy.com">ezoerner@ebuddy.com</a>
 */
public class ThriftStructuredDataSupportTest {
    private static final int MAX_CODE_POINT = 0x10FFFF;

    @Mock
    private ColumnFamilyOperations<String,String,Object> operations;

    private ThriftStructuredDataSupport<String> dao ;
    private final String rowKey = "rowKey";
    private final TypeReference<TestPojo> typeReference = new TypeReference<TestPojo>() { };
    private Path path;

    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        dao = new ThriftStructuredDataSupport<String>(operations);
        path = dao.createPath("a","b","c");
    }

    @Test(groups = {"unit"})
    public void shouldReadFromPath() throws Exception {

        Map<String,Object> stringObjectMap = getExpectedMap(false);

        when(operations.readColumnsAsMap(rowKey,
                                         "a/b/c/",
                                         getFinishString("a/b/c/"),
                                         Integer.MAX_VALUE,
                                         false)).thenReturn(stringObjectMap);