Package com.tistory.devyongsik.crescent.collection.entity

Source Code of com.tistory.devyongsik.crescent.collection.entity.LuceneFieldBuilderTest

package com.tistory.devyongsik.crescent.collection.entity;

import java.util.Map;
import java.util.Set;

import javax.annotation.PostConstruct;

import org.apache.lucene.index.IndexableField;
import org.junit.Assert;
import org.junit.Test;

import com.tistory.devyongsik.crescent.config.CrescentCollectionHandler;
import com.tistory.devyongsik.crescent.config.SpringApplicationContext;
import com.tistory.devyongsik.crescent.index.LuceneFieldBuilder;
import com.tistory.devyongsik.utils.CrescentTestCaseUtil;

public class LuceneFieldBuilderTest extends CrescentTestCaseUtil {

  @PostConstruct
  public void init() {
    super.init();
  }

  @Test
  public void create() {
    CrescentCollectionHandler collectionHandler
    = SpringApplicationContext.getBean("crescentCollectionHandler", CrescentCollectionHandler.class);
   
    CrescentCollections crescentCollections = collectionHandler.getCrescentCollections();

    Map<String, CrescentCollection> collections = crescentCollections.getCrescentCollectionsMap();

    CrescentCollection sampleCollection = collections.get("sample");

   
    Map<String, CrescentCollectionField> fieldsByName = sampleCollection.getCrescentFieldByName();
   
    Set<String> fieldNames = fieldsByName.keySet();
    LuceneFieldBuilder luceneFieldBuilder = new LuceneFieldBuilder();
   
    for(String fieldName : fieldNames) {
      CrescentCollectionField field = fieldsByName.get(fieldName);
      IndexableField luceneField = luceneFieldBuilder.create(field, "30");
     
      System.out.println(luceneField);
     
      Assert.assertNotNull(luceneField);
    }
  }
}
TOP

Related Classes of com.tistory.devyongsik.crescent.collection.entity.LuceneFieldBuilderTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.