<commit_before>/*
 * 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.Arrays;

import org.junit.Test;

public class RoleTest extends SDKTestCase {
    @Test
    public void testSymmetricAccessors() {
        Role role = service.getRoles().create(createTemporaryName());
        try {
            role.setCapabilities(new String[] { "admin_all_objects" });
            role.setDefaultApp("search");
            role.setImportedRoles(new String[] { "user" });
            role.setSearchDiskQuota(9000);
            role.setSearchFilter("*");
            role.setSearchIndexesAllowed(new String[] { "*" });
            role.setSearchIndexesDefault(new String[] { "main" });
            role.setSearchJobsQuota(49);
            
            role.setRealTimeSearchJobsQuota(99);
            role.setSearchTimeWindow(99);
            
            role.update();
            role.refresh();
            
            assertEquals(new String[] { "admin_all_objects" }, role.getCapabilities());
            assertEquals("search", role.getDefaultApp());
            assertEquals(new String[] { "user" }, role.getImportedRoles());
            assertEquals(9000, role.getSearchDiskQuota());
            assertEquals("*", role.getSearchFilter());
            assertEquals(new String[] { "*" }, role.getSearchIndexesAllowed());
            assertEquals(new String[] { "main" }, role.getSearchIndexesDefault());
            assertEquals(49, role.getSearchJobsQuota());
            
            assertEquals(99, role.getRealTimeSearchJobsQuota());
            assertEquals(99, role.getSearchTimeWindow());
        }
        finally {
            role.remove();
        }
    }
    
    @Test
    public void testArrayPromotingSetters() {
        Role role = service.getRoles().create(createTemporaryName());
        try {
            role.setCapabilities("admin_all_objects");
            role.setImportedRoles("user");
            role.setSearchIndexesAllowed("*");
            role.setSearchIndexesDefault("main");
            
            role.update();
            role.refresh();<commit_msg>Test get/set searchIndexesDefault on Role with multiple values.<commit_after>/*
 * 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.Arrays;
import java.util.List;

import org.junit.Test;

public class RoleTest extends SDKTestCase {
    @Test
    public void testSymmetricAccessors() {
        Role role = service.getRoles().create(createTemporaryName());
        try {
            role.setCapabilities(new String[] { "admin_all_objects" });
            role.setDefaultApp("search");
            role.setImportedRoles(new String[] { "user" });
            role.setSearchDiskQuota(9000);
            role.setSearchFilter("*");
            role.setSearchIndexesAllowed(new String[] { "*" });
            role.setSearchIndexesDefault(new String[] { "main", "_internal" });
            role.setSearchJobsQuota(49);
            
            role.setRealTimeSearchJobsQuota(99);
            role.setSearchTimeWindow(99);
            
            role.update();
            role.refresh();
            
            assertEquals(new String[] { "admin_all_objects" }, role.getCapabilities());
            assertEquals("search", role.getDefaultApp());
            assertEquals(new String[] { "user" }, role.getImportedRoles());
            assertEquals(9000, role.getSearchDiskQuota());
            assertEquals("*", role.getSearchFilter());
            assertEquals(new String[] { "*" }, role.getSearchIndexesAllowed());
            List<String> defaultIndexes = Arrays.asList(role.getSearchIndexesDefault());
            assertEquals(2, defaultIndexes.size());
            assertTrue(defaultIndexes.contains("main"));
            assertTrue(defaultIndexes.contains("_internal"));
            assertEquals(49, role.getSearchJobsQuota());
            
            assertEquals(99, role.getRealTimeSearchJobsQuota());
            assertEquals(99, role.getSearchTimeWindow());
        }
        finally {
            role.remove();
        }
    }
    
    @Test
    public void testArrayPromotingSetters() {
        Role role = service.getRoles().create(createTemporaryName());
        try {
            role.setCapabilities("admin_all_objects");
            role.setImportedRoles("user");
            role.setSearchIndexesAllowed("*");
            role.setSearchIndexesDefault("main");
            
            role.update();
            role.refresh();
{'fraction_non_alphanumeric': 0.11395807203010214, 'fraction_numerical': 0.010213223436660097, 'mean_word_length': 2.4735532047293094, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1858074', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1432, 'n_words': 340}