<commit_before>/*******************************************************************************
 * Copyright 2015, The IKANOW Open Source Project.
 * 
 * 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.ikanow.aleph2.data_model.objects.data_import;

import static org.junit.Assert.*;

import java.util.Arrays;

import org.junit.Test;

import com.google.common.collect.ImmutableMap;

public class TestDataSchemaBean {

	@Test 
	public void testAccessors() {
		
		// Storage Schema Bean
		
		DataSchemaBean.StorageSchemaBean empty_storage_bean = new DataSchemaBean.StorageSchemaBean();
		assertEquals("Empty Storage Bean", empty_storage_bean.service_name(), null);		
		
		DataSchemaBean.StorageSchemaBean storage_bean =
				new DataSchemaBean.StorageSchemaBean(
						true,
						"service_name",
						"raw_grouping_time_period",
						"raw_exist_age_max",
						"json_grouping_time_period",
						"json_exist_age_max",
						"processed_grouping_time_period",
						"processed_exist_age_max",
						ImmutableMap.<String, Object>builder().put("technology_override", "schema").build()
						);
		
		assertEquals("Storage bean enabled", storage_bean.enabled(), true);
		assertEquals("Storage bean service_name", storage_bean.service_name(), "service_name");
		assertEquals("Storage bean raw_grouping_time_period", storage_bean.raw_grouping_time_period(), "raw_grouping_time_period");
		assertEquals("Storage bean json_grouping_time_period", storage_bean.json_grouping_time_period(), "json_grouping_time_period");
		assertEquals("Storage bean processed_grouping_time_period", storage_bean.processed_grouping_time_period(), "processed_grouping_time_period");
		assertEquals("Storage bean raw_exist_age_max", storage_bean.raw_exist_age_max(), "raw_exist_age_max");
		assertEquals("Storage bean json_exist_age_max", storage_bean.json_exist_age_max(), "json_exist_age_max");
		assertEquals("Storage bean processed_exist_age_max", storage_bean.processed_exist_age_max(), "processed_exist_age_max");
		assertEquals("Storage bean technology_override_schema", storage_bean.technology_override_schema(), ImmutableMap.<String, Object>builder().put("technology_override", "schema").build());
		
		// Document Bean
		
		DataSchemaBean.DocumentSchemaBean empty_document_bean = new DataSchemaBean.DocumentSchemaBean();
		assertEquals("Empty Document Bean", empty_document_bean.service_name(), null);		
		
		DataSchemaBean.DocumentSchemaBean document_bean =
				new DataSchemaBean.DocumentSchemaBean(
						true,
						"service_name",
						false,
						Arrays.asList("deduplication_fields"),
						ImmutableMap.<String, Object>builder().put("technology_override", "schema").build()
						);
		
		assertEquals("Document bean enabled", document_bean.enabled(), true);
		assertEquals("Document bean service_name", document_bean.service_name(), "service_name");
		assertEquals("Document bean deduplicate", document_bean.deduplicate(), false);
		assertEquals("Document bean deduplication_fields", document_bean.deduplication_fields(), Arrays.asList("deduplication_fields"));
		assertEquals("Document bean technology_override_schema", document_bean.technology_override_schema(), ImmutableMap.<String, Object>builder().put("technology_override", "schema").build());
		
		// Search Index Bean
		
		DataSchemaBean.SearchIndexSchemaBean empty_search_index_bean = new DataSchemaBean.SearchIndexSchemaBean();
		assertEquals("Empty Search Index Bean", empty_search_index_bean.service_name(), null);		
		
		DataSchemaBean.SearchIndexSchemaBean search_index_bean =
				new DataSchemaBean.SearchIndexSchemaBean(
						true,
						"service_name",
						ImmutableMap.<String, Object>builder().put("technology_override", "schema").build()
						);

		assertEquals("Search Index bean enabled", search_index_bean.enabled(), true);
		assertEquals("Search Index bean service_name", search_index_bean.service_name(), "service_name");
		assertEquals("Search Index bean technology_override_schema", search_index_bean.technology_override_schema(), ImmutableMap.<String, Object>builder().put("technology_override", "schema").build());
		
		// Columnar Bean:
		
		DataSchemaBean.ColumnarSchemaBean empty_columnar_bean = new DataSchemaBean.ColumnarSchemaBean();
		assertEquals("Empty Columnar Bean", empty_columnar_bean.service_name(), null);		
		
		DataSchemaBean.ColumnarSchemaBean columnar_bean =
				new DataSchemaBean.ColumnarSchemaBean(
						true,
						"service_name",
						Arrays.asList("field_include_list"),
						Arrays.asList("field_exclude_list"),
						Arrays.asList("field_include_pattern"),
						Arrays.asList("field_exclude_pattern"),
						Arrays.asList("field_type_include_list"),
						Arrays.asList("field_type_exclude_list"),
						ImmutableMap.<String, Object>builder().put("technology_override", "schema").build()
						);
		
		assertEquals("Columnar bean enabled", columnar_bean.enabled(), true);
		assertEquals("Columnar bean service_name", columnar_bean.service_name(), "service_name");
		assertEquals("Columnar bean field_include_list", columnar_bean.field_include_list(), Arrays.asList("field_include_list"));
		assertEquals("Columnar bean field_exclude_list", columnar_bean.field_exclude_list(), Arrays.asList("field_exclude_list"));
		assertEquals("Columnar bean field_include_regex", columnar_bean.field_include_pattern_list(), "field_include_regex");
		assertEquals("Columnar bean field_exclude_regex", columnar_bean.field_exclude_pattern_list(), "field_exclude_regex");
		assertEquals("Columnar bean field_type_include_list", columnar_bean.field_type_include_list(), Arrays.asList("field_type_include_list"));
		assertEquals("Columnar bean field_type_exclude_list", columnar_bean.field_type_exclude_list(), Arrays.asList("field_type_exclude_list"));
		assertEquals("Columnar bean technology_override_schema", columnar_bean.technology_override_schema(), ImmutableMap.<String, Object>builder().put("technology_override", "schema").build());
		
		// Temporal
		
		DataSchemaBean.TemporalSchemaBean empty_temporal_bean = new DataSchemaBean.TemporalSchemaBean();
		assertEquals("Empty Temporal Bean", empty_temporal_bean.service_name(), null);		
		
		DataSchemaBean.TemporalSchemaBean temporal_bean =
				new DataSchemaBean.TemporalSchemaBean(
						true,
						"service_name",
						"grouping_time_period",<commit_msg>ALEPH-14 Yet more mapping logic<commit_after>/*******************************************************************************
 * Copyright 2015, The IKANOW Open Source Project.
 * 
 * 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.ikanow.aleph2.data_model.objects.data_import;

import static org.junit.Assert.*;

import java.util.Arrays;

import org.junit.Test;

import com.google.common.collect.ImmutableMap;

public class TestDataSchemaBean {

	@Test 
	public void testAccessors() {
		
		// Storage Schema Bean
		
		DataSchemaBean.StorageSchemaBean empty_storage_bean = new DataSchemaBean.StorageSchemaBean();
		assertEquals("Empty Storage Bean", empty_storage_bean.service_name(), null);		
		
		DataSchemaBean.StorageSchemaBean storage_bean =
				new DataSchemaBean.StorageSchemaBean(
						true,
						"service_name",
						"raw_grouping_time_period",
						"raw_exist_age_max",
						"json_grouping_time_period",
						"json_exist_age_max",
						"processed_grouping_time_period",
						"processed_exist_age_max",
						ImmutableMap.<String, Object>builder().put("technology_override", "schema").build()
						);
		
		assertEquals("Storage bean enabled", storage_bean.enabled(), true);
		assertEquals("Storage bean service_name", storage_bean.service_name(), "service_name");
		assertEquals("Storage bean raw_grouping_time_period", storage_bean.raw_grouping_time_period(), "raw_grouping_time_period");
		assertEquals("Storage bean json_grouping_time_period", storage_bean.json_grouping_time_period(), "json_grouping_time_period");
		assertEquals("Storage bean processed_grouping_time_period", storage_bean.processed_grouping_time_period(), "processed_grouping_time_period");
		assertEquals("Storage bean raw_exist_age_max", storage_bean.raw_exist_age_max(), "raw_exist_age_max");
		assertEquals("Storage bean json_exist_age_max", storage_bean.json_exist_age_max(), "json_exist_age_max");
		assertEquals("Storage bean processed_exist_age_max", storage_bean.processed_exist_age_max(), "processed_exist_age_max");
		assertEquals("Storage bean technology_override_schema", storage_bean.technology_override_schema(), ImmutableMap.<String, Object>builder().put("technology_override", "schema").build());
		
		// Document Bean
		
		DataSchemaBean.DocumentSchemaBean empty_document_bean = new DataSchemaBean.DocumentSchemaBean();
		assertEquals("Empty Document Bean", empty_document_bean.service_name(), null);		
		
		DataSchemaBean.DocumentSchemaBean document_bean =
				new DataSchemaBean.DocumentSchemaBean(
						true,
						"service_name",
						false,
						Arrays.asList("deduplication_fields"),
						ImmutableMap.<String, Object>builder().put("technology_override", "schema").build()
						);
		
		assertEquals("Document bean enabled", document_bean.enabled(), true);
		assertEquals("Document bean service_name", document_bean.service_name(), "service_name");
		assertEquals("Document bean deduplicate", document_bean.deduplicate(), false);
		assertEquals("Document bean deduplication_fields", document_bean.deduplication_fields(), Arrays.asList("deduplication_fields"));
		assertEquals("Document bean technology_override_schema", document_bean.technology_override_schema(), ImmutableMap.<String, Object>builder().put("technology_override", "schema").build());
		
		// Search Index Bean
		
		DataSchemaBean.SearchIndexSchemaBean empty_search_index_bean = new DataSchemaBean.SearchIndexSchemaBean();
		assertEquals("Empty Search Index Bean", empty_search_index_bean.service_name(), null);		
		
		DataSchemaBean.SearchIndexSchemaBean search_index_bean =
				new DataSchemaBean.SearchIndexSchemaBean(
						true,
						"service_name",
						ImmutableMap.<String, Object>builder().put("technology_override", "schema").build()
						);

		assertEquals("Search Index bean enabled", search_index_bean.enabled(), true);
		assertEquals("Search Index bean service_name", search_index_bean.service_name(), "service_name");
		assertEquals("Search Index bean technology_override_schema", search_index_bean.technology_override_schema(), ImmutableMap.<String, Object>builder().put("technology_override", "schema").build());
		
		// Columnar Bean:
		
		DataSchemaBean.ColumnarSchemaBean empty_columnar_bean = new DataSchemaBean.ColumnarSchemaBean();
		assertEquals("Empty Columnar Bean", empty_columnar_bean.service_name(), null);		
		
		DataSchemaBean.ColumnarSchemaBean columnar_bean =
				new DataSchemaBean.ColumnarSchemaBean(
						true,
						"service_name",
						Arrays.asList("field_include_list"),
						Arrays.asList("field_exclude_list"),
						Arrays.asList("field_include_pattern"),
						Arrays.asList("field_exclude_pattern"),
						Arrays.asList("field_type_include_list"),
						Arrays.asList("field_type_exclude_list"),
						ImmutableMap.<String, Object>builder().put("technology_override", "schema").build()
						);
		
		assertEquals("Columnar bean enabled", columnar_bean.enabled(), true);
		assertEquals("Columnar bean service_name", columnar_bean.service_name(), "service_name");
		assertEquals("Columnar bean field_include_list", columnar_bean.field_include_list(), Arrays.asList("field_include_list"));
		assertEquals("Columnar bean field_exclude_list", columnar_bean.field_exclude_list(), Arrays.asList("field_exclude_list"));
		assertEquals("Columnar bean field_include_pattern_list", columnar_bean.field_include_pattern_list(), "field_include_pattern_list");
		assertEquals("Columnar bean field_exclude_pattern_list", columnar_bean.field_exclude_pattern_list(), "field_exclude_pattern_list");
		assertEquals("Columnar bean field_type_include_list", columnar_bean.field_type_include_list(), Arrays.asList("field_type_include_list"));
		assertEquals("Columnar bean field_type_exclude_list", columnar_bean.field_type_exclude_list(), Arrays.asList("field_type_exclude_list"));
		assertEquals("Columnar bean technology_override_schema", columnar_bean.technology_override_schema(), ImmutableMap.<String, Object>builder().put("technology_override", "schema").build());
		
		// Temporal
		
		DataSchemaBean.TemporalSchemaBean empty_temporal_bean = new DataSchemaBean.TemporalSchemaBean();
		assertEquals("Empty Temporal Bean", empty_temporal_bean.service_name(), null);		
		
		DataSchemaBean.TemporalSchemaBean temporal_bean =
				new DataSchemaBean.TemporalSchemaBean(
						true,
						"service_name",
						"grouping_time_period",
{'fraction_non_alphanumeric': 0.12666184971098265, 'fraction_numerical': 0.001445086705202312, 'mean_word_length': 6.465480043149946, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '7254926', 'n_tokens_mistral': 4361, 'n_tokens_neox': 3665, 'n_words': 721}