/*
 * Copyright 2011 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.sdk.tests.com.splunk;

import com.splunk.*;
import com.splunk.sdk.Command;
import com.splunk.Service;

import junit.framework.Assert;
import junit.framework.TestCase;
import org.junit.*;

public class EventTypeTest extends TestCase {
    Command command;

    public EventTypeTest() {}

    Service connect() {
        return Service.connect(command.opts);
    }

    @Before public void setUp() {
        command = Command.splunk(); // Pick up .splunkrc settings
    }

    @Test public void testEventType() throws Exception {
        Service service = connect();

        EntityCollection<EventType> ds = service.getEventTypes();

        for (EventType entity: ds.values()) {
            entity.get(); // force a read
            Assert.assertTrue(entity.getPriority() != -1);
            Assert.assertTrue(entity.getSearch() != null);
            entity.getDescription();
            //UNDONE: more?
        }
    }
}

@@ -1211,17 +1211,18 @@
 ntType%3E 
-d
+et
 s = serv
@@ -1241,16 +1241,419 @@
 Types();
+%0A        if (ets.containsKey(%22sdk-test%22)) %7B%0A            ets.remove(%22sdk-test%22);%0A        %7D%0A%0A        Assert.assertFalse(ets.containsKey(%22sdk-test%22));%0A        Args args = new Args();%0A        args.put(%22search%22,%22index=_internal *%22);%0A        args.put(%22description%22, %22Dummy description%22);%0A        args.put(%22disabled%22, true);%0A        args.put(%22priority%22, 2);%0A        EventType et = ets.create(%22sdk-test%22, args);
 %0A%0A      
@@ -1677,17 +1677,18 @@
 entity: 
-d
+et
 s.values
@@ -1902,37 +1902,934 @@
     
-    //UNDONE: more?%0A        %7D
+%7D%0A%0A        Assert.assertEquals(et.getDescription(), args.get(%22description%22));%0A        Assert.assertEquals(et.getSearch(), args.get(%22search%22));%0A        Assert.assertEquals(et.getPriority(), args.get(%22priority%22));%0A        Assert.assertEquals(et.getName(), %22sdk-test%22);%0A        Assert.assertTrue(et.isDisabled());%0A%0A        args.clear();%0A        args.put(%22search%22, %22index=_audit *%22);%0A        args.put(%22description%22, %22Dummy description a second time%22);%0A        args.put(%22priority%22, 3);%0A        et.update(args);%0A        et.enable();%0A%0A        Assert.assertEquals(et.getDescription(), args.get(%22description%22));%0A        Assert.assertEquals(et.getSearch(), args.get(%22search%22));%0A        Assert.assertEquals(et.getPriority(), args.get(%22priority%22));%0A        Assert.assertEquals(et.getName(), %22sdk-test%22);%0A        Assert.assertFalse(et.isDisabled());%0A%0A        ets.remove(%22sdk-test%22);%0A        Assert.assertFalse(ets.containsKey(%22sdk-test%22));
 %0A   

Update Event test to read modify write.