# Testing docFieldLongs

**URL:** <https://discuss.elastic.co/t/testing-docfieldlongs/16356>\
**Category:** Elasticsearch\
**Created:** [March 13, 2014, 4:22pm UTC](https://discuss.elastic.co/t/testing-docfieldlongs/16356 "2014-03-13T16:22:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redrubia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redrubia/32/1554_2.png) [@redrubia](https://discuss.elastic.co/u/redrubia)\
**Post date:** [March 13, 2014, 4:22pm UTC](https://discuss.elastic.co/t/testing-docfieldlongs/16356/1 "2014-03-13T16:22:32Z")

</div>

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 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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c3642fc6-57cf-496e-813f-a2b761b1b25f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c3642fc6-57cf-496e-813f-a2b761b1b25f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:43am UTC](https://discuss.elastic.co/t/testing-docfieldlongs/16356/2 "2017-07-06T01:43:25Z")

</div>

Closed on July 6, 2017, 1:43am UTC


