-
Notifications
You must be signed in to change notification settings - Fork 14
/
MetamodelMocks.java
453 lines (372 loc) · 13.4 KB
/
MetamodelMocks.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
/**
* Copyright (C) 2016 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.environment.utils;
import cz.cvut.kbss.jopa.environment.*;
import cz.cvut.kbss.jopa.model.metamodel.*;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.Date;
import java.util.Set;
import static org.mockito.Mockito.when;
/**
* Provides metamodel mock objects for the test classes.
*/
public class MetamodelMocks {
@Mock
private EntityType<OWLClassA> etA;
@Mock
private Identifier idA;
@Mock
private SingularAttribute<OWLClassA, String> aStringAtt;
@Mock
private TypesSpecification<OWLClassA, ?> aTypes;
@Mock
private EntityType<OWLClassB> etB;
@Mock
private Identifier idB;
@Mock
private SingularAttribute<OWLClassB, String> bStringAtt;
@Mock
private PropertiesSpecification<OWLClassB, ?> bProperties;
@Mock
private EntityType<OWLClassC> etC;
@Mock
private Identifier idC;
@Mock
private ListAttribute<OWLClassC, OWLClassA> cReferencedList;
@Mock
private ListAttribute<OWLClassC, OWLClassA> cSimpleList;
@Mock
private EntityType<OWLClassD> etD;
@Mock
private Identifier idD;
@Mock
private SingularAttribute<OWLClassD, OWLClassA> dOwlClassAAtt;
@Mock
private EntityType<OWLClassE> etE;
@Mock
private Identifier idE;
@Mock
private SingularAttribute<OWLClassE, String> eStringAtt;
@Mock
private EntityType<OWLClassG> etG;
@Mock
private Identifier idG;
@Mock
private SingularAttribute<OWLClassG, OWLClassH> gOwlClassHAtt;
@Mock
private EntityType<OWLClassF> etF;
@Mock
private Identifier idF;
@Mock
private SingularAttribute<OWLClassF, String> fStringAtt;
@Mock
private PluralAttribute<OWLClassF, Set, OWLClassA> fSetAtt;
@Mock
private EntityType<OWLClassH> etH;
@Mock
private Identifier idH;
@Mock
private SingularAttribute<OWLClassH, OWLClassA> hOwlClassAAtt;
@Mock
private SingularAttribute<OWLClassH, OWLClassG> hOwlClassGAtt;
@Mock
private EntityType<OWLClassJ> etJ;
@Mock
private Identifier idJ;
@Mock
private PluralAttribute<OWLClassJ, Set, OWLClassA> jSetAtt;
@Mock
private EntityType<OWLClassK> etK;
@Mock
private Identifier idK;
@Mock
private SingularAttribute<OWLClassK, OWLClassE> kOwlClassEAtt;
@Mock
private EntityType<OWLClassL> etL;
@Mock
private Identifier idL;
@Mock
private ListAttribute<OWLClassL, OWLClassA> lSimpleList;
@Mock
private ListAttribute<OWLClassL, OWLClassA> lReferencedList;
@Mock
private PluralAttribute<OWLClassL, Set, OWLClassA> lSetAtt;
@Mock
private SingularAttribute<OWLClassL, OWLClassA> lOwlClassAAtt;
@Mock
private EntityType<OWLClassM> etM;
@Mock
private Identifier idM;
@Mock
private SingularAttribute<OWLClassM, Boolean> mBooleanAtt;
@Mock
private SingularAttribute<OWLClassM, Integer> mIntegerAtt;
@Mock
private SingularAttribute<OWLClassM, Long> mLongAtt;
@Mock
private SingularAttribute<OWLClassM, Double> mDoubleAtt;
@Mock
private SingularAttribute<OWLClassM, Date> mDateAtt;
@Mock
private SingularAttribute<OWLClassM, OWLClassM.Severity> mEnumAtt;
@Mock
private EntityType<OWLClassO> etO;
@Mock
private Identifier idO;
@Mock
private SingularAttribute<OWLClassO, String> oStringAtt;
public MetamodelMocks() throws Exception {
MockitoAnnotations.initMocks(this);
MetamodelFactory.initOWLClassAMocks(etA, aStringAtt, aTypes, idA);
MetamodelFactory.initOWLClassBMocks(etB, bStringAtt, bProperties, idB);
MetamodelFactory.initOWLClassCMocks(etC, cSimpleList, cReferencedList, idC);
MetamodelFactory.initOWLClassDMocks(etD, dOwlClassAAtt, idD);
MetamodelFactory.initOWLClassEMocks(etE, eStringAtt, idE);
MetamodelFactory.initOWLClassFMocks(etF, fSetAtt, fStringAtt, idF);
MetamodelFactory.iniOWLClassGMocks(etG, gOwlClassHAtt, idG);
MetamodelFactory.initOWLClassHMocks(etH, hOwlClassAAtt, hOwlClassGAtt, idH);
MetamodelFactory.initOWLClassJMocks(etJ, jSetAtt, idJ);
MetamodelFactory.initOWLClassKMocks(etK, kOwlClassEAtt, idK);
MetamodelFactory.initOWLClassLMocks(etL, lReferencedList, lSimpleList, lSetAtt, lOwlClassAAtt, idL);
MetamodelFactory
.initOWLClassMMock(etM, mBooleanAtt, mIntegerAtt, mLongAtt, mDoubleAtt, mDateAtt, mEnumAtt, idM);
MetamodelFactory.initOWLClassOMock(etO, oStringAtt, idO);
}
public void setMocks(Metamodel metamodel) {
when(metamodel.entity(OWLClassA.class)).thenReturn(etA);
when(metamodel.entity(OWLClassB.class)).thenReturn(etB);
when(metamodel.entity(OWLClassC.class)).thenReturn(etC);
when(metamodel.entity(OWLClassD.class)).thenReturn(etD);
when(metamodel.entity(OWLClassE.class)).thenReturn(etE);
when(metamodel.entity(OWLClassF.class)).thenReturn(etF);
when(metamodel.entity(OWLClassG.class)).thenReturn(etG);
when(metamodel.entity(OWLClassH.class)).thenReturn(etH);
when(metamodel.entity(OWLClassJ.class)).thenReturn(etJ);
when(metamodel.entity(OWLClassK.class)).thenReturn(etK);
when(metamodel.entity(OWLClassL.class)).thenReturn(etL);
when(metamodel.entity(OWLClassM.class)).thenReturn(etM);
when(metamodel.entity(OWLClassO.class)).thenReturn(etO);
}
public OWLClassAMetamodel forOwlClassA() {
return new OWLClassAMetamodel();
}
public OWLClassBMetamodel forOwlClassB() {
return new OWLClassBMetamodel();
}
public OWLClassCMetamodel forOwlClassC() {
return new OWLClassCMetamodel();
}
public OWLClassDMetamodel forOwlClassD() {
return new OWLClassDMetamodel();
}
public OWLClassEMetamodel forOwlClassE() {
return new OWLClassEMetamodel();
}
public OWLClassJMetamodel forOwlClassJ() {
return new OWLClassJMetamodel();
}
public OWLClassKMetamodel forOwlClassK() {
return new OWLClassKMetamodel();
}
public OWLClassLMetamodel forOwlClassL() {
return new OWLClassLMetamodel();
}
public OWLClassMMetamodel forOwlClassM() {
return new OWLClassMMetamodel();
}
public class OWLClassAMetamodel {
public EntityType<OWLClassA> entityType() {
return MetamodelMocks.this.etA;
}
public Identifier identifier() {
return MetamodelMocks.this.idA;
}
public SingularAttribute<OWLClassA, String> stringAttribute() {
return MetamodelMocks.this.aStringAtt;
}
public TypesSpecification<OWLClassA, ?> typesSpec() {
return MetamodelMocks.this.aTypes;
}
}
public class OWLClassBMetamodel {
public EntityType<OWLClassB> entityType() {
return MetamodelMocks.this.etB;
}
public Identifier identifier() {
return MetamodelMocks.this.idB;
}
public SingularAttribute<OWLClassB, String> stringAttribute() {
return MetamodelMocks.this.bStringAtt;
}
public PropertiesSpecification<OWLClassB, ?> propertiesSpec() {
return MetamodelMocks.this.bProperties;
}
}
public class OWLClassCMetamodel {
public EntityType<OWLClassC> entityType() {
return MetamodelMocks.this.etC;
}
public Identifier identifier() {
return MetamodelMocks.this.idC;
}
public ListAttribute<OWLClassC, OWLClassA> referencedListAtt() {
return MetamodelMocks.this.cReferencedList;
}
public ListAttribute<OWLClassC, OWLClassA> simpleListAtt() {
return MetamodelMocks.this.cSimpleList;
}
}
public class OWLClassDMetamodel {
public EntityType<OWLClassD> entityType() {
return MetamodelMocks.this.etD;
}
public Identifier identifier() {
return MetamodelMocks.this.idD;
}
public SingularAttribute<OWLClassD, OWLClassA> owlClassAAtt() {
return MetamodelMocks.this.dOwlClassAAtt;
}
}
public class OWLClassEMetamodel {
public EntityType<OWLClassE> entityType() {
return MetamodelMocks.this.etE;
}
public Identifier identifier() {
return MetamodelMocks.this.idE;
}
public SingularAttribute<OWLClassE, String> stringAttribute() {
return MetamodelMocks.this.eStringAtt;
}
}
public class OWLClassFMetamodel {
public EntityType<OWLClassF> entityType() {
return MetamodelMocks.this.etF;
}
public Identifier identifier() {
return MetamodelMocks.this.idF;
}
public SingularAttribute<OWLClassF, String> stringAttribute() {
return MetamodelMocks.this.fStringAtt;
}
public PluralAttribute<OWLClassF, Set, OWLClassA> setAttribute() {
return MetamodelMocks.this.fSetAtt;
}
}
public class OWLClassGMetamodel {
public EntityType<OWLClassG> entityType() {
return MetamodelMocks.this.etG;
}
public Identifier identifier() {
return MetamodelMocks.this.idG;
}
public SingularAttribute<OWLClassG, OWLClassH> owlClassHAtt() {
return MetamodelMocks.this.gOwlClassHAtt;
}
}
public class OWLClassHMetamodel {
public EntityType<OWLClassH> entityType() {
return MetamodelMocks.this.etH;
}
public Identifier identifier() {
return MetamodelMocks.this.idH;
}
public SingularAttribute<OWLClassH, OWLClassG> owlClassGAtt() {
return MetamodelMocks.this.hOwlClassGAtt;
}
public SingularAttribute<OWLClassH, OWLClassA> owlClassAAtt() {
return MetamodelMocks.this.hOwlClassAAtt;
}
}
public class OWLClassJMetamodel {
public EntityType<OWLClassJ> entityType() {
return MetamodelMocks.this.etJ;
}
public Identifier identifier() {
return MetamodelMocks.this.idJ;
}
public PluralAttribute<OWLClassJ, Set, OWLClassA> setAttribute() {
return MetamodelMocks.this.jSetAtt;
}
}
public class OWLClassKMetamodel {
public EntityType<OWLClassK> entityType() {
return MetamodelMocks.this.etK;
}
public Identifier identifier() {
return MetamodelMocks.this.idK;
}
public SingularAttribute<OWLClassK, OWLClassE> owlClassEAtt() {
return MetamodelMocks.this.kOwlClassEAtt;
}
}
public class OWLClassLMetamodel {
public EntityType<OWLClassL> entityType() {
return MetamodelMocks.this.etL;
}
public Identifier identifier() {
return MetamodelMocks.this.idL;
}
public ListAttribute<OWLClassL, OWLClassA> referencedListAtt() {
return MetamodelMocks.this.lReferencedList;
}
public ListAttribute<OWLClassL, OWLClassA> simpleListAtt() {
return MetamodelMocks.this.lSimpleList;
}
public PluralAttribute<OWLClassL, Set, OWLClassA> setAttribute() {
return MetamodelMocks.this.lSetAtt;
}
public SingularAttribute<OWLClassL, OWLClassA> owlClassAAtt() {
return MetamodelMocks.this.lOwlClassAAtt;
}
}
public class OWLClassMMetamodel {
public EntityType<OWLClassM> entityType() {
return MetamodelMocks.this.etM;
}
public Identifier identifier() {
return MetamodelMocks.this.idM;
}
public SingularAttribute<OWLClassM, Boolean> booleanAttribute() {
return MetamodelMocks.this.mBooleanAtt;
}
public SingularAttribute<OWLClassM, Integer> integerAttribute() {
return MetamodelMocks.this.mIntegerAtt;
}
public SingularAttribute<OWLClassM, Long> longAttribute() {
return MetamodelMocks.this.mLongAtt;
}
public SingularAttribute<OWLClassM, Double> doubleAttribute() {
return MetamodelMocks.this.mDoubleAtt;
}
public SingularAttribute<OWLClassM, Date> dateAttribute() {
return MetamodelMocks.this.mDateAtt;
}
public SingularAttribute<OWLClassM, OWLClassM.Severity> enumAttribute() {
return MetamodelMocks.this.mEnumAtt;
}
}
public class OWLClassOMetamodel {
public EntityType<OWLClassO> entityType() {
return MetamodelMocks.this.etO;
}
public Identifier identifier() {
return MetamodelMocks.this.idO;
}
public SingularAttribute<OWLClassO, String> stringAttribute() {
return MetamodelMocks.this.oStringAtt;
}
}
}