// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/TestRunners.java
// public interface CloudTests {
// }
// 
// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/TestRunners.java
// public interface DevFabricTests {
// }
// 
// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/TestRunners.java
// public interface DevStoreTests {
// }
// 
// Path: microsoft-azure-storage/src/com/microsoft/azure/storage/table/TableRequestOptions.java
// public interface PropertyResolver {
// 
//     /**
//      * Given the partition key, row, key, and the property name, produces the EdmType
//      * 
//      * @param pk
//      *            A <code>String</code> which represents the partition key.
//      * @param rk
//      *            A <code>String</code> which represents the row key.
//      * @param key
//      *            A <code>String</code> which represents the property name.
//      * @param value
//      *            A <code>String</code> which represents the property value.
//      * @return
//      *         The {@link EdmType} of the property.
//      */
//     public EdmType propertyResolver(String pk, String rk, String key, String value);
// 
// }
// 
// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/table/TableTestHelper.java
// public static class Class1 extends TableServiceEntity implements PropertyResolver {
// 
//     public String A;
// 
//     public String B;
// 
//     public String C;
// 
//     public byte[] D;
// 
//     public Class1() {
//         // empty ctor
//     }
// 
//     public Class1(String pk, String rk) {
//         super(pk, rk);
//     }
// 
//     public synchronized String getA() {
//         return this.A;
//     }
// 
//     public synchronized String getB() {
//         return this.B;
//     }
// 
//     public synchronized String getC() {
//         return this.C;
//     }
// 
//     public synchronized byte[] getD() {
//         return this.D;
//     }
// 
//     public synchronized void setA(final String a) {
//         this.A = a;
//     }
// 
//     public synchronized void setB(final String b) {
//         this.B = b;
//     }
// 
//     public synchronized void setC(final String c) {
//         this.C = c;
//     }
// 
//     public synchronized void setD(final byte[] d) {
//         this.D = d;
//     }
// 
//     @Override
//     public EdmType propertyResolver(String pk, String rk, String key, String value) {
//         if (key.equals("A")) {
//             return EdmType.STRING;
//         }
//         else if (key.equals("B")) {
//             return EdmType.STRING;
//         }
//         else if (key.equals("C")) {
//             return EdmType.STRING;
//         }
//         else if (key.equals("D")) {
//             return EdmType.BINARY;
//         }
//         return null;
//     }
// }


import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.TestRunners.CloudTests;
import com.microsoft.azure.storage.TestRunners.DevFabricTests;
import com.microsoft.azure.storage.TestRunners.DevStoreTests;
import com.microsoft.azure.storage.table.TableRequestOptions.PropertyResolver;
import com.microsoft.azure.storage.table.TableTestHelper.Class1;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.net.URISyntaxException;
import java.util.UUID;
import static org.junit.Assert.*;
/**
 * Copyright Microsoft Corporation
 *
 * 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.microsoft.azure.storage.table;





@Category({ DevFabricTests.class, DevStoreTests.class, CloudTests.class })
public class TableODataTests {

    TableRequestOptions options;
    DynamicTableEntity ent;

    private CloudTable table;

    @Before
    public void tableODataTestBeforeMethodSetUp() throws StorageException, URISyntaxException {
        this.table = TableTestHelper.getRandomTableReference();
        this.table.createIfNotExists();

        final CloudTableClient tClient = TableTestHelper.createCloudTableClient();
        this.options = TableRequestOptions.populateAndApplyDefaults(this.options, tClient);
        this.options.setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata);

        // Insert Entity
        this.ent = new DynamicTableEntity();
        this.ent.setPartitionKey("jxscl_odata");
        this.ent.setRowKey(UUID.randomUUID().toString());

        this.ent.getProperties().put("foo2", new EntityProperty("bar2"));
        this.ent.getProperties().put("foo", new EntityProperty("bar"));
        this.ent.getProperties().put("fooint", new EntityProperty(1234));

        this.table.execute(TableOperation.insert(this.ent), this.options, null);
    }

    @After
    public void tableODataTestBeforeMethodTearDown() throws StorageException {
        this.table.execute(TableOperation.delete(this.ent), this.options, null);
        this.table.deleteIfExists();
    }

    @Test
    public void testTableOperationRetrieveJsonNoMetadataFail() {

        // set custom property resolver
        this.options.setPropertyResolver(new CustomPropertyResolver());

        try {
// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/TestRunners.java
// public interface CloudTests {
// }
// 
// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/TestRunners.java
// public interface DevFabricTests {
// }
// 
// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/TestRunners.java
// public interface DevStoreTests {
// }
// 
// Path: microsoft-azure-storage/src/com/microsoft/azure/storage/table/TableRequestOptions.java
// public interface PropertyResolver {
// 
//     /**
//      * Given the partition key, row, key, and the property name, produces the EdmType
//      * 
//      * @param pk
//      *            A <code>String</code> which represents the partition key.
//      * @param rk
//      *            A <code>String</code> which represents the row key.
//      * @param key
//      *            A <code>String</code> which represents the property name.
//      * @param value
//      *            A <code>String</code> which represents the property value.
//      * @return
//      *         The {@link EdmType} of the property.
//      */
//     public EdmType propertyResolver(String pk, String rk, String key, String value);
// 
// }
// 
// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/table/TableTestHelper.java
// public static class Class1 extends TableServiceEntity implements PropertyResolver {
// 
//     public String A;
// 
//     public String B;
// 
//     public String C;
// 
//     public byte[] D;
// 
//     public Class1() {
//         // empty ctor
//     }
// 
//     public Class1(String pk, String rk) {
//         super(pk, rk);
//     }
// 
//     public synchronized String getA() {
//         return this.A;
//     }
// 
//     public synchronized String getB() {
//         return this.B;
//     }
// 
//     public synchronized String getC() {
//         return this.C;
//     }
// 
//     public synchronized byte[] getD() {
//         return this.D;
//     }
// 
//     public synchronized void setA(final String a) {
//         this.A = a;
//     }
// 
//     public synchronized void setB(final String b) {
//         this.B = b;
//     }
// 
//     public synchronized void setC(final String c) {
//         this.C = c;
//     }
// 
//     public synchronized void setD(final byte[] d) {
//         this.D = d;
//     }
// 
//     @Override
//     public EdmType propertyResolver(String pk, String rk, String key, String value) {
//         if (key.equals("A")) {
//             return EdmType.STRING;
//         }
//         else if (key.equals("B")) {
//             return EdmType.STRING;
//         }
//         else if (key.equals("C")) {
//             return EdmType.STRING;
//         }
//         else if (key.equals("D")) {
//             return EdmType.BINARY;
//         }
//         return null;
//     }
// }


// Path: microsoft-azure-storage-test/src/com/microsoft/azure/storage/table/TableODataTests.java
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.TestRunners.CloudTests;
import com.microsoft.azure.storage.TestRunners.DevFabricTests;
import com.microsoft.azure.storage.TestRunners.DevStoreTests;
import com.microsoft.azure.storage.table.TableRequestOptions.PropertyResolver;
import com.microsoft.azure.storage.table.TableTestHelper.Class1;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.net.URISyntaxException;
import java.util.UUID;
import static org.junit.Assert.*;

/**
 * Copyright Microsoft Corporation
 *
 * 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.microsoft.azure.storage.table;





@Category({ DevFabricTests.class, DevStoreTests.class, CloudTests.class })
public class TableODataTests {

    TableRequestOptions options;
    DynamicTableEntity ent;

    private CloudTable table;

    @Before
    public void tableODataTestBeforeMethodSetUp() throws StorageException, URISyntaxException {
        this.table = TableTestHelper.getRandomTableReference();
        this.table.createIfNotExists();

        final CloudTableClient tClient = TableTestHelper.createCloudTableClient();
        this.options = TableRequestOptions.populateAndApplyDefaults(this.options, tClient);
        this.options.setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata);

        // Insert Entity
        this.ent = new DynamicTableEntity();
        this.ent.setPartitionKey("jxscl_odata");
        this.ent.setRowKey(UUID.randomUUID().toString());

        this.ent.getProperties().put("foo2", new EntityProperty("bar2"));
        this.ent.getProperties().put("foo", new EntityProperty("bar"));
        this.ent.getProperties().put("fooint", new EntityProperty(1234));

        this.table.execute(TableOperation.insert(this.ent), this.options, null);
    }

    @After
    public void tableODataTestBeforeMethodTearDown() throws StorageException {
        this.table.execute(TableOperation.delete(this.ent), this.options, null);
        this.table.deleteIfExists();
    }

    @Test
    public void testTableOperationRetrieveJsonNoMetadataFail() {

        // set custom property resolver
        this.options.setPropertyResolver(new CustomPropertyResolver());

        try {
            this.table.execute(TableOperation.retrieve(this.ent.getPartitionKey(), this.ent.getRowKey(), Class1.class),