I have a function, in which I call docFieldLongs. In unit testing I need to 
create and override this function and also return ScriptDocValues.Longs.

    @Test
    public void testRunAsLongs throws Exception()
    {
        script = new MaxiScoreScript(params){
            @Override
            protected ScriptDocValues.Longs docFieldLongs(String getter){
                IndexWriter writer = new IndexWriter(new RAMDirectory(), 
new IndexWriterConfig(Lucene.VERSION, new                       
StandardAnalyzer(Lucene.VERSION)).setMergePolicy(new 
LogByteSizeMergePolicy()));
                Document d  = new Document();
                d.add(new LongField("value", 102, Field.Store.NO));
                d.add(new LongField("value" ,101, Field.Store.NO));
                writer.addDocument(d);

                IndexNumericFieldData indexFieldData = 
IndexFieldDataService.getForField("value");
                AtomicNumericFieldData fieldData = 
indexFieldData.load(refreshReader());

                AtomicNumericFieldData temp = fieldData;

                // return (ScriptDocValues.Longs) temp.getScriptValues();
            }

        }


    }


The main aim of this is to get the same type returned. However I am having 
a few issues with this, with regards to refreshReader.  I also feel this is 
a very long winded way of doing things.

In summary, I simply want to override `docFiledLongs`, to `return 
ScriptDocValues.Longs` which I have defined. In my function, I call 
docFieldLongs("docFieldItems").getValues();

I want this statement when tested to return a List<Long> items, being 
[101L,102L].

Any help would be greatly appreciated.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/c3642fc6-57cf-496e-813f-a2b761b1b25f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to