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.jmock.lib.concurrent.Synchroniser;
18 import org.junit.jupiter.api.extension.RegisterExtension;
19
20 import java.io.IOException;
21 import java.io.Reader;
22
23 import edu.umd.cs.findbugs.annotations.NonNull;
24
25 public class AbstractBoundModelTestSupport
26 extends AbstractMetaschemaTest {
27 @RegisterExtension
28 JUnit5Mockery context = new JUnit5Mockery() {
29 {
30 setThreadingPolicy(new Synchroniser());
31 }
32 };
33
34 @NonNull
35 protected JUnit5Mockery getJUnit5Mockery() {
36 return ObjectUtils.requireNonNull(context);
37 }
38
39 @NonNull
40 protected IBoundDefinitionModelAssembly getRootAssemblyClassBinding() throws IOException {
41 return ObjectUtils.requireNonNull((IBoundDefinitionModelAssembly) newBindingContext()
42 .getBoundDefinitionForClass(RootBoundAssembly.class));
43 }
44
45 @SuppressWarnings("resource")
46 @NonNull
47 protected JsonParser newJsonParser(@NonNull Reader reader) throws JsonParseException, IOException {
48 JsonFactory factory = new JsonFactory();
49 JsonParser jsonParser = factory.createParser(reader);
50 return ObjectUtils.notNull(jsonParser);
51 }
52 }