1b5840353SAdam Hornáček /* 2b5840353SAdam Hornáček * CDDL HEADER START 3b5840353SAdam Hornáček * 4b5840353SAdam Hornáček * The contents of this file are subject to the terms of the 5b5840353SAdam Hornáček * Common Development and Distribution License (the "License"). 6b5840353SAdam Hornáček * You may not use this file except in compliance with the License. 7b5840353SAdam Hornáček * 8b5840353SAdam Hornáček * See LICENSE.txt included in this distribution for the specific 9b5840353SAdam Hornáček * language governing permissions and limitations under the License. 10b5840353SAdam Hornáček * 11b5840353SAdam Hornáček * When distributing Covered Code, include this CDDL HEADER in each 12b5840353SAdam Hornáček * file and include the License file at LICENSE.txt. 13b5840353SAdam Hornáček * If applicable, add the following below this CDDL HEADER, with the 14b5840353SAdam Hornáček * fields enclosed by brackets "[]" replaced with your own identifying 15b5840353SAdam Hornáček * information: Portions Copyright [yyyy] [name of copyright owner] 16b5840353SAdam Hornáček * 17b5840353SAdam Hornáček * CDDL HEADER END 18b5840353SAdam Hornáček */ 19b5840353SAdam Hornáček 20b5840353SAdam Hornáček /* 21b5840353SAdam Hornáček * Copyright (c) 2018, Chris Fraire <cfraire@me.com>. 22b5840353SAdam Hornáček */ 239805b761SAdam Hornáček package org.opengrok.indexer.index; 24b5840353SAdam Hornáček 25b5840353SAdam Hornáček import java.io.IOException; 261161d3e8SAdam Hornacek 2752d10766SAdam Hornacek import org.junit.jupiter.api.Test; 289805b761SAdam Hornáček import org.opengrok.indexer.search.QueryBuilder; 29b5840353SAdam Hornáček 3052d10766SAdam Hornacek import static org.junit.jupiter.api.Assertions.assertEquals; 3152d10766SAdam Hornacek import static org.junit.jupiter.api.Assertions.assertNotNull; 3252d10766SAdam Hornacek import static org.junit.jupiter.api.Assertions.assertNull; 3352d10766SAdam Hornacek 34b5840353SAdam Hornáček /** 35b5840353SAdam Hornáček * Represents a test class for {@link IndexAnalysisSettings}. 36b5840353SAdam Hornáček */ 37b5840353SAdam Hornáček public class IndexAnalysisSettingsTest { 38b5840353SAdam Hornáček 39b5840353SAdam Hornáček private static final String PROJECT_NAME = "foo-1-2-3"; 40b5840353SAdam Hornáček private static final long ANALYZER_GURU_VERSION = 3; 41b5840353SAdam Hornáček private static final int TABSIZE = 17; 42b5840353SAdam Hornáček 43b5840353SAdam Hornáček @Test shouldAffirmIndexAnalysisSettingsObjuid()44*d6df19e1SAdam Hornacek public void shouldAffirmIndexAnalysisSettingsObjuid() { 451161d3e8SAdam Hornacek String objuid = QueryBuilder.normalizeDirPath("58859C75-F941-42E5-8D1A-FAF71DDEBBA7"); 4652d10766SAdam Hornacek assertEquals(objuid, IndexAnalysisSettingsAccessor.INDEX_ANALYSIS_SETTINGS_OBJUID, 4752d10766SAdam Hornacek "IndexAnalysisSettingsDao objuid"); 48b5840353SAdam Hornáček } 49b5840353SAdam Hornáček 50b5840353SAdam Hornáček @Test shouldRoundTripANullObject()511161d3e8SAdam Hornacek public void shouldRoundTripANullObject() throws IOException, ClassNotFoundException { 52b5840353SAdam Hornáček IndexAnalysisSettings obj = new IndexAnalysisSettings(); 53b5840353SAdam Hornáček byte[] bin = obj.serialize(); 54b5840353SAdam Hornáček 55b5840353SAdam Hornáček IndexAnalysisSettings res = IndexAnalysisSettings.deserialize(bin); 56b5840353SAdam Hornáček assertNotNull(res); 5752d10766SAdam Hornacek assertNull(res.getProjectName(), "projectName"); 5852d10766SAdam Hornacek assertNull(res.getTabSize(), "tabSize"); 5952d10766SAdam Hornacek assertNull(res.getAnalyzerGuruVersion(), "analyzerGuruVersion"); 60b5840353SAdam Hornáček } 61b5840353SAdam Hornáček 62b5840353SAdam Hornáček @Test shouldRoundTripADefinedObject()63b5840353SAdam Hornáček public void shouldRoundTripADefinedObject() throws IOException, 64b5840353SAdam Hornáček ClassNotFoundException { 65b5840353SAdam Hornáček IndexAnalysisSettings obj = new IndexAnalysisSettings(); 66b5840353SAdam Hornáček obj.setProjectName(PROJECT_NAME); 67b5840353SAdam Hornáček obj.setAnalyzerGuruVersion(ANALYZER_GURU_VERSION); 68b5840353SAdam Hornáček obj.setTabSize(TABSIZE); 69b5840353SAdam Hornáček byte[] bin = obj.serialize(); 70b5840353SAdam Hornáček 71b5840353SAdam Hornáček IndexAnalysisSettings res = IndexAnalysisSettings.deserialize(bin); 72b5840353SAdam Hornáček assertNotNull(res); 7352d10766SAdam Hornacek assertEquals(PROJECT_NAME, res.getProjectName(), "projectName"); 7452d10766SAdam Hornacek assertEquals(TABSIZE, (int) res.getTabSize(), "tabSize"); 7552d10766SAdam Hornacek assertEquals(ANALYZER_GURU_VERSION, (long) res.getAnalyzerGuruVersion(), "analyzerGuruVersion"); 76b5840353SAdam Hornáček } 77b5840353SAdam Hornáček } 78