37
37
import org .mockito .Mockito ;
38
38
39
39
import java .io .IOException ;
40
- import java .util .Collections ;
41
- import java .util .Set ;
42
40
43
41
public class TypeFieldTypeTests extends FieldTypeTestCase {
44
42
@ Override
@@ -60,26 +58,27 @@ public void testTermsQuery() throws Exception {
60
58
Mockito .when (context .indexVersionCreated ()).thenReturn (indexVersionCreated );
61
59
62
60
MapperService mapperService = Mockito .mock (MapperService .class );
63
- Set <String > types = Collections .emptySet ();
64
- Mockito .when (mapperService .types ()).thenReturn (types );
61
+ Mockito .when (mapperService .documentMapper ()).thenReturn (null );
65
62
Mockito .when (context .getMapperService ()).thenReturn (mapperService );
66
63
67
64
TypeFieldMapper .TypeFieldType ft = new TypeFieldMapper .TypeFieldType ();
68
65
ft .setName (TypeFieldMapper .NAME );
69
66
Query query = ft .termQuery ("my_type" , context );
70
67
assertEquals (new MatchNoDocsQuery (), query );
71
68
72
- types = Collections .singleton ("my_type" );
73
- Mockito .when (mapperService .types ()).thenReturn (types );
69
+ DocumentMapper mapper = Mockito .mock (DocumentMapper .class );
70
+ Mockito .when (mapper .type ()).thenReturn ("my_type" );
71
+ Mockito .when (mapperService .documentMapper ()).thenReturn (mapper );
74
72
query = ft .termQuery ("my_type" , context );
75
73
assertEquals (new MatchAllDocsQuery (), query );
76
74
77
75
Mockito .when (mapperService .hasNested ()).thenReturn (true );
78
76
query = ft .termQuery ("my_type" , context );
79
77
assertEquals (Queries .newNonNestedFilter (context .indexVersionCreated ()), query );
80
78
81
- types = Collections .singleton ("other_type" );
82
- Mockito .when (mapperService .types ()).thenReturn (types );
79
+ mapper = Mockito .mock (DocumentMapper .class );
80
+ Mockito .when (mapper .type ()).thenReturn ("other_type" );
81
+ Mockito .when (mapperService .documentMapper ()).thenReturn (mapper );
83
82
query = ft .termQuery ("my_type" , context );
84
83
assertEquals (new MatchNoDocsQuery (), query );
85
84
}
0 commit comments