X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=parser%2Fyang-parser-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Frepo%2FSchemaContextFactoryDeviationsTest.java;h=706f00fb13e090f9e211590a9a0622f44b623d17;hb=973a7bd5be04bd9a63f4b7f6305cb25b5532cae9;hp=fb035a41b834ffa809305282f1761cb78f114976;hpb=6dd19d2f87b3391b95d8087a3ff025c5414fd4e9;p=yangtools.git diff --git a/parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SchemaContextFactoryDeviationsTest.java b/parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SchemaContextFactoryDeviationsTest.java index fb035a41b8..706f00fb13 100644 --- a/parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SchemaContextFactoryDeviationsTest.java +++ b/parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SchemaContextFactoryDeviationsTest.java @@ -12,16 +12,10 @@ import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.SetMultimap; -import com.google.common.util.concurrent.ListenableFuture; import java.util.Optional; -import java.util.concurrent.ExecutionException; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; @@ -51,63 +45,47 @@ public class SchemaContextFactoryDeviationsTest extends AbstractSchemaRepository private static final QNameModule BAZ_MODULE = QNameModule.create(BAZ_NS, REVISION); @Test - public void testDeviationsSupportedInSomeModules() throws Exception { - final SetMultimap modulesWithSupportedDeviations = - ImmutableSetMultimap.builder() - .put(FOO_MODULE, BAR_MODULE) - .put(FOO_MODULE, BAZ_MODULE) - .put(BAR_MODULE, BAZ_MODULE) - .build(); + public void testDeviationsSupportedInSomeModules() { + final var context = assertModelContext(ImmutableSetMultimap.builder() + .put(FOO_MODULE, BAR_MODULE) + .put(FOO_MODULE, BAZ_MODULE) + .put(BAR_MODULE, BAZ_MODULE) + .build(), + FOO, BAR, BAZ, FOOBAR); - final ListenableFuture lf = createSchemaContext(modulesWithSupportedDeviations, FOO, BAR, - BAZ, FOOBAR); - assertTrue(lf.isDone()); - final EffectiveModelContext schemaContext = lf.get(); - assertNotNull(schemaContext); - - assertAbsent(schemaContext, MY_FOO_CONT_A); - assertAbsent(schemaContext, MY_FOO_CONT_B); - assertPresent(schemaContext, MY_FOO_CONT_C); - assertAbsent(schemaContext, MY_BAR_CONT_A); - assertPresent(schemaContext, MY_BAR_CONT_B); + assertAbsent(context, MY_FOO_CONT_A); + assertAbsent(context, MY_FOO_CONT_B); + assertPresent(context, MY_FOO_CONT_C); + assertAbsent(context, MY_BAR_CONT_A); + assertPresent(context, MY_BAR_CONT_B); } @Test - public void testDeviationsSupportedInAllModules() throws Exception { - final ListenableFuture lf = createSchemaContext(null, FOO, BAR, BAZ, FOOBAR); - assertTrue(lf.isDone()); - final EffectiveModelContext schemaContext = lf.get(); - assertNotNull(schemaContext); + public void testDeviationsSupportedInAllModules() { + final var context = assertModelContext(null, FOO, BAR, BAZ, FOOBAR); - assertAbsent(schemaContext, MY_FOO_CONT_A); - assertAbsent(schemaContext, MY_FOO_CONT_B); - assertAbsent(schemaContext, MY_FOO_CONT_C); - assertAbsent(schemaContext, MY_BAR_CONT_A); - assertAbsent(schemaContext, MY_BAR_CONT_B); + assertAbsent(context, MY_FOO_CONT_A); + assertAbsent(context, MY_FOO_CONT_B); + assertAbsent(context, MY_FOO_CONT_C); + assertAbsent(context, MY_BAR_CONT_A); + assertAbsent(context, MY_BAR_CONT_B); } @Test - public void testDeviationsSupportedInNoModule() throws Exception { - final ListenableFuture lf = createSchemaContext(ImmutableSetMultimap.of(), FOO, BAR, BAZ, - FOOBAR); - assertTrue(lf.isDone()); - final EffectiveModelContext schemaContext = lf.get(); - assertNotNull(schemaContext); + public void testDeviationsSupportedInNoModule() { + final var context = assertModelContext(ImmutableSetMultimap.of(), FOO, BAR, BAZ, FOOBAR); - assertPresent(schemaContext, MY_FOO_CONT_A); - assertPresent(schemaContext, MY_FOO_CONT_B); - assertPresent(schemaContext, MY_FOO_CONT_C); - assertPresent(schemaContext, MY_BAR_CONT_A); - assertPresent(schemaContext, MY_BAR_CONT_B); + assertPresent(context, MY_FOO_CONT_A); + assertPresent(context, MY_FOO_CONT_B); + assertPresent(context, MY_FOO_CONT_C); + assertPresent(context, MY_BAR_CONT_A); + assertPresent(context, MY_BAR_CONT_B); } @Test - public void shouldFailOnAttemptToDeviateTheSameModule2() throws Exception { - final ListenableFuture lf = createSchemaContext(null, BAR_INVALID, BAZ_INVALID); - assertTrue(lf.isDone()); + public void shouldFailOnAttemptToDeviateTheSameModule2() { + final var cause = Throwables.getRootCause(assertExecutionException(null, BAR_INVALID, BAZ_INVALID)); - final ExecutionException ex = assertThrows(ExecutionException.class, lf::get); - final Throwable cause = Throwables.getRootCause(ex); assertThat(cause, instanceOf(InferenceException.class)); assertThat(cause.getMessage(), startsWith("Deviation must not target the same module as the one it is defined in"));