1
2
3
4
5
6 package gov.nist.secauto.metaschema.databind.model;
7
8 import com.fasterxml.jackson.core.JsonFactory;
9 import com.fasterxml.jackson.core.JsonParseException;
10 import com.fasterxml.jackson.core.JsonParser;
11
12 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
13 import gov.nist.secauto.metaschema.databind.codegen.AbstractMetaschemaTest;
14 import gov.nist.secauto.metaschema.databind.model.test.RootBoundAssembly;
15
16 import org.jmock.junit5.JUnit5Mockery;
17 import org.junit.jupiter.api.extension.RegisterExtension;
18
19 import java.io.IOException;
20 import java.io.Reader;
21
22 import edu.umd.cs.findbugs.annotations.NonNull;
23
24 public class AbstractBoundModelTestSupport
25 extends AbstractMetaschemaTest {
26 @RegisterExtension
27 JUnit5Mockery context = new JUnit5Mockery();
28
29 @NonNull
30 protected JUnit5Mockery getJUnit5Mockery() {
31 return ObjectUtils.requireNonNull(context);
32 }
33
34 @NonNull
35 protected IBoundDefinitionModelAssembly getRootAssemblyClassBinding() throws IOException {
36 return ObjectUtils.requireNonNull((IBoundDefinitionModelAssembly) newBindingContext()
37 .getBoundDefinitionForClass(RootBoundAssembly.class));
38 }
39
40 @SuppressWarnings("resource")
41 @NonNull
42 protected JsonParser newJsonParser(@NonNull Reader reader) throws JsonParseException, IOException {
43 JsonFactory factory = new JsonFactory();
44 JsonParser jsonParser = factory.createParser(reader);
45 return ObjectUtils.notNull(jsonParser);
46 }
47 }