/*
 * Copyright 2012 Splunk, Inc.
 *
 * 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.splunk;

import java.util.Map;

import org.junit.Test;

public class EntityTest extends SDKTestCase {
    private static final String QUERY = "search index=_internal | head 10";
    
    private static final String KEY = "isSavedSearch";
    private static final String VALUE = "0";

    @Test
    public void testMapOverrides() {
        Entity entity = service.getJobs().create(QUERY);
        
        assertFalse(entity.isEmpty());
        assertEquals(VALUE, entity.get(KEY));
        assertTrue(entity.containsKey(KEY));
        assertTrue(entity.containsValue(VALUE));
        assertTrue(entity.keySet().contains(KEY));
        assertTrue(entity.values().contains(VALUE));
        for (Map.Entry<String, Object> e : entity.entrySet()) {
            assertTrue(entity.containsKey(e.getKey()));
            assertTrue(entity.containsValue(e.getValue()));
        }
        
        try {
            entity.putAll(null);
            fail("Expected UnsupportedOperationException.");
        } catch (UnsupportedOperationException e) {
            // Good
        }
        
        try {
            entity.clear();
            fail("Expected UnsupportedOperationException.");
        } catch (UnsupportedOperationException e) {
            // Good
        }
        
        try {
            entity.remove(null);
            fail("Expected UnsupportedOperationException.");
        } catch (UnsupportedOperationException e) {
            // Good
        }
    }
}

@@ -1487,32 +1487,234 @@
  %0A        try %7B%0A
+            entity.put(null, null);%0A            fail(%22Expected UnsupportedOperationException.%22);%0A        %7D catch (UnsupportedOperationException e) %7B%0A            // Good%0A        %7D%0A        %0A        try %7B%0A
             enti

Test Entity.put().