<commit_before>/*
 * DISCLAIMER
 *
 * Copyright 2018 ArangoDB GmbH, Cologne, Germany
 *
 * 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.
 *
 * Copyright holder is ArangoDB GmbH, Cologne, Germany
 */

package com.arangodb;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;

import java.util.Collection;
import java.util.concurrent.ExecutionException;

import org.junit.BeforeClass;
import org.junit.Test;

import com.arangodb.entity.ViewEntity;
import com.arangodb.entity.ViewType;
import com.arangodb.entity.arangosearch.ArangoSearchPropertiesEntity;
import com.arangodb.entity.arangosearch.CollectionLink;
import com.arangodb.entity.arangosearch.ConsolidationPolicy;
import com.arangodb.entity.arangosearch.ConsolidationType;
import com.arangodb.entity.arangosearch.FieldLink;
import com.arangodb.entity.arangosearch.StoreValuesType;
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
import com.arangodb.model.arangosearch.ArangoSearchPropertiesOptions;

/**
 * @author <NAME>
 *
 */
public class ArangoSearchTest extends BaseTest {

	private static final String VIEW_NAME = "view_test";

	@BeforeClass
	public static void setup() throws InterruptedException, ExecutionException {
		if (!requireVersion(arangoDB, 3, 4)) {
			return;
		}
		db.createArangoSearch(VIEW_NAME, new ArangoSearchCreateOptions()).get();
	}

	@Test
	public void exists() throws InterruptedException, ExecutionException {
		if (!requireVersion(3, 4)) {
			return;
		}
		assertThat(db.arangoSearch(VIEW_NAME).exists().get(), is(true));
	}

	@Test
	public void getInfo() throws InterruptedException, ExecutionException {
		if (!requireVersion(3, 4)) {
			return;
		}
		final ViewEntity info = db.arangoSearch(VIEW_NAME).getInfo().get();
		assertThat(info, is(not(nullValue())));
		assertThat(info.getId(), is(not(nullValue())));
		assertThat(info.getName(), is(VIEW_NAME));
		assertThat(info.getType(), is(ViewType.ARANGO_SEARCH));
	}

	@Test
	public void drop() throws InterruptedException, ExecutionException {
		if (!requireVersion(3, 4)) {
			return;
		}
		final String name = VIEW_NAME + "_droptest";
		db.createArangoSearch(name, new ArangoSearchCreateOptions()).get();
		final ArangoViewAsync view = db.arangoSearch(name);
		view.drop().get();
		assertThat(view.exists().get(), is(false));
	}

	@Test
	public void rename() throws InterruptedException, ExecutionException {
		if (!requireVersion(3, 4)) {
			return;
		}
		final String name = VIEW_NAME + "_renametest";
		final String newName = name + "_new";
		db.createArangoSearch(name, new ArangoSearchCreateOptions()).get();
		db.arangoSearch(name).rename(newName).get();<commit_msg>do not execute rename test in cluster<commit_after>/*
 * DISCLAIMER
 *
 * Copyright 2018 ArangoDB GmbH, Cologne, Germany
 *
 * 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.
 *
 * Copyright holder is ArangoDB GmbH, Cologne, Germany
 */

package com.arangodb;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;

import java.util.Collection;
import java.util.concurrent.ExecutionException;

import org.junit.BeforeClass;
import org.junit.Test;

import com.arangodb.entity.ServerRole;
import com.arangodb.entity.ViewEntity;
import com.arangodb.entity.ViewType;
import com.arangodb.entity.arangosearch.ArangoSearchPropertiesEntity;
import com.arangodb.entity.arangosearch.CollectionLink;
import com.arangodb.entity.arangosearch.ConsolidationPolicy;
import com.arangodb.entity.arangosearch.ConsolidationType;
import com.arangodb.entity.arangosearch.FieldLink;
import com.arangodb.entity.arangosearch.StoreValuesType;
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
import com.arangodb.model.arangosearch.ArangoSearchPropertiesOptions;

/**
 * @author <NAME>
 *
 */
public class ArangoSearchTest extends BaseTest {

	private static final String VIEW_NAME = "view_test";

	@BeforeClass
	public static void setup() throws InterruptedException, ExecutionException {
		if (!requireVersion(arangoDB, 3, 4)) {
			return;
		}
		db.createArangoSearch(VIEW_NAME, new ArangoSearchCreateOptions()).get();
	}

	@Test
	public void exists() throws InterruptedException, ExecutionException {
		if (!requireVersion(3, 4)) {
			return;
		}
		assertThat(db.arangoSearch(VIEW_NAME).exists().get(), is(true));
	}

	@Test
	public void getInfo() throws InterruptedException, ExecutionException {
		if (!requireVersion(3, 4)) {
			return;
		}
		final ViewEntity info = db.arangoSearch(VIEW_NAME).getInfo().get();
		assertThat(info, is(not(nullValue())));
		assertThat(info.getId(), is(not(nullValue())));
		assertThat(info.getName(), is(VIEW_NAME));
		assertThat(info.getType(), is(ViewType.ARANGO_SEARCH));
	}

	@Test
	public void drop() throws InterruptedException, ExecutionException {
		if (!requireVersion(3, 4)) {
			return;
		}
		final String name = VIEW_NAME + "_droptest";
		db.createArangoSearch(name, new ArangoSearchCreateOptions()).get();
		final ArangoViewAsync view = db.arangoSearch(name);
		view.drop().get();
		assertThat(view.exists().get(), is(false));
	}

	@Test
	public void rename() throws InterruptedException, ExecutionException {
		if (arangoDB.getRole().get() != ServerRole.SINGLE) {
			return;
		}
		if (!requireVersion(3, 4)) {
			return;
		}
		final String name = VIEW_NAME + "_renametest";
		final String newName = name + "_new";
		db.createArangoSearch(name, new ArangoSearchCreateOptions()).get();
		db.arangoSearch(name).rename(newName).get();
{'fraction_non_alphanumeric': 0.11336641106600512, 'fraction_numerical': 0.005412719891745603, 'mean_word_length': 5.222637979420019, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1078757', 'n_tokens_mistral': 2185, 'n_tokens_neox': 2041, 'n_words': 513}