Search in sources :

Example 1 with RevisionIdentifier

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier in project netconf by opendaylight.

the class ModuleBuilderTest method testModuleBuilder.

@Test
public void testModuleBuilder() {
    final ModuleBuilder moduleBuilder = new ModuleBuilder();
    final Module.Revision revision = new Module.Revision(new RevisionIdentifier("2016-10-11"));
    final YangIdentifier yangIdentifierOne = new YangIdentifier("YangIdentifier1");
    final YangIdentifier yangIdentifierTwo = new YangIdentifier("YangIdentifier2");
    final Uri namespace = new Uri("namespace");
    final List<YangIdentifier> yangIdentifierList = ImmutableList.of(yangIdentifierOne, yangIdentifierTwo);
    final ModuleKey moduleKeyOne = new ModuleKey(yangIdentifierOne, revision);
    final ModuleKey moduleKeyTwo = new ModuleKey(moduleKeyOne);
    moduleBuilder.setRevision(revision);
    moduleBuilder.setDeviation(yangIdentifierList);
    moduleBuilder.setFeature(yangIdentifierList);
    moduleBuilder.setName(yangIdentifierOne);
    moduleBuilder.setNamespace(namespace);
    moduleBuilder.withKey(moduleKeyOne);
    final Module moduleOne = moduleBuilder.build();
    final Module moduleTwo = new ModuleBuilder(moduleOne).build();
    assertNotNull(moduleBuilder);
    assertNotNull(revision);
    assertNotNull(yangIdentifierOne);
    assertNotNull(yangIdentifierTwo);
    assertNotNull(namespace);
    assertNotNull(yangIdentifierList);
    assertNotNull(moduleKeyOne);
    assertNotNull(moduleKeyOne.hashCode());
    assertNotNull(moduleKeyOne.toString());
    assertNotNull(moduleBuilder.toString());
    assertNotNull(moduleBuilder.hashCode());
    assertEquals(moduleKeyOne, moduleKeyTwo);
    assertEquals(revision, moduleKeyOne.getRevision());
    assertEquals(yangIdentifierOne, moduleKeyOne.getName());
    assertEquals(revision, moduleBuilder.getRevision());
    assertEquals(yangIdentifierList, moduleBuilder.getDeviation());
    assertEquals(yangIdentifierList, moduleBuilder.getFeature());
    assertEquals(yangIdentifierOne, moduleBuilder.getName());
    assertEquals(namespace, moduleBuilder.getNamespace());
    assertEquals(moduleKeyOne, moduleBuilder.key());
    assertEquals(moduleOne.toString(), moduleTwo.toString());
    assertEquals(moduleKeyOne.toString(), moduleKeyTwo.toString());
    assertTrue(moduleOne.equals(moduleTwo));
    assertTrue(moduleKeyOne.equals(moduleKeyTwo));
}
Also used : RevisionIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) YangIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier) Test(org.junit.Test)

Example 2 with RevisionIdentifier

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier in project netconf by opendaylight.

the class RevisionBuilderTest method testValidDataString.

@Test
public void testValidDataString() {
    final String dateString = "2014-04-23";
    final Revision revision = RevisionBuilder.getDefaultInstance(dateString);
    validate(revision, null, new RevisionIdentifier(dateString));
}
Also used : Revision(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision) RevisionIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier) Test(org.junit.Test)

Example 3 with RevisionIdentifier

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier in project netconf by opendaylight.

the class YangLibraryTest method createTestModuleSet.

private static YangLibrary createTestModuleSet() {
    Submodule sub = new SubmoduleBuilder().setName(new YangIdentifier("test-submodule")).setRevision(ImportOnlyModuleRevisionBuilder.emptyRevision().getRevisionIdentifier()).build();
    Module modules = new ModuleBuilder().setName(new YangIdentifier("test-module_2013-07-22")).setNamespace(new Uri("test:namespace")).setRevision(new RevisionIdentifier("2013-07-22")).setSubmodule(ImmutableMap.of(sub.key(), sub)).build();
    Module yangLibrary = new ModuleBuilder().setName(new YangIdentifier("ietf-yang-library_2019-01-04")).setNamespace(new Uri("urn:ietf:params:xml:ns:yang:ietf-yang-library")).setRevision(new RevisionIdentifier("2019-01-04")).build();
    ModuleSet modulesSet = new ModuleSetBuilder().setName("state-modules").setModule(ImmutableMap.of(modules.key(), modules, yangLibrary.key(), yangLibrary)).build();
    Schema schema = new SchemaBuilder().setName("state-schema").setModuleSet(Collections.singletonList(modulesSet.getName())).build();
    Datastore datastore = new DatastoreBuilder().setName(Operational.class).setSchema(schema.getName()).build();
    return new YangLibraryBuilder().setModuleSet(BindingMap.of(modulesSet)).setSchema(BindingMap.of(schema)).setDatastore(BindingMap.of(datastore)).setContentId("0").build();
}
Also used : ModuleBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.ModuleBuilder) Schema(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.yang.library.parameters.Schema) Submodule(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.module.Submodule) SubmoduleBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.module.SubmoduleBuilder) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) ModuleSetBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.yang.library.parameters.ModuleSetBuilder) YangLibraryBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibraryBuilder) Datastore(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.yang.library.parameters.Datastore) SchemaBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.yang.library.parameters.SchemaBuilder) ModuleSet(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.yang.library.parameters.ModuleSet) RevisionIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.RevisionIdentifier) Module(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.Module) YangIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier) DatastoreBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.yang.library.parameters.DatastoreBuilder)

Example 4 with RevisionIdentifier

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier in project netconf by opendaylight.

the class YangLibProviderTest method testSchemaSourceRegistered.

@Test
public void testSchemaSourceRegistered() {
    yangLibProvider.init();
    when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
    doNothing().when(writeTransaction).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(InstanceIdentifier.create(ModulesState.class)), any());
    List<PotentialSchemaSource<?>> list = new ArrayList<>();
    list.add(PotentialSchemaSource.create(RevisionSourceIdentifier.create("no-revision"), YangTextSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
    list.add(PotentialSchemaSource.create(RevisionSourceIdentifier.create("with-revision", org.opendaylight.yangtools.yang.common.Revision.of("2016-04-28")), YangTextSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
    doReturn(emptyFluentFuture()).when(writeTransaction).commit();
    yangLibProvider.schemaSourceRegistered(list);
    Map<ModuleKey, Module> newModulesList = new HashMap<>();
    Module newModule = new ModuleBuilder().setName(new YangIdentifier("no-revision")).setRevision(RevisionUtils.emptyRevision()).setSchema(new Uri("http://www.fake.com:300/yanglib/schemas/no-revision/")).build();
    newModulesList.put(newModule.key(), newModule);
    newModule = new ModuleBuilder().setName(new YangIdentifier("with-revision")).setRevision(new Revision(new RevisionIdentifier("2016-04-28"))).setSchema(new Uri("http://www.fake.com:300/yanglib/schemas/with-revision/2016-04-28")).build();
    newModulesList.put(newModule.key(), newModule);
    verify(dataBroker).newWriteOnlyTransaction();
    verify(writeTransaction).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(InstanceIdentifier.create(ModulesState.class)), eq(new ModulesStateBuilder().setModule(newModulesList).build()));
    verify(writeTransaction).commit();
}
Also used : YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) ModulesStateBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesStateBuilder) HashMap(java.util.HashMap) ModuleBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleBuilder) ArrayList(java.util.ArrayList) PotentialSchemaSource(org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) Revision(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision) RevisionIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier) Module(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module) ModuleKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleKey) YangIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier) Test(org.junit.Test)

Example 5 with RevisionIdentifier

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier in project netconf by opendaylight.

the class YangLibProviderTest method testSchemaSourceUnregistered.

@Test
public void testSchemaSourceUnregistered() {
    yangLibProvider.init();
    when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
    doNothing().when(writeTransaction).delete(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
    doReturn(emptyFluentFuture()).when(writeTransaction).commit();
    PotentialSchemaSource<YangTextSchemaSource> yangUnregistererSource = PotentialSchemaSource.create(RevisionSourceIdentifier.create("unregistered-yang-schema-without-revision"), YangTextSchemaSource.class, PotentialSchemaSource.Costs.LOCAL_IO.getValue());
    yangLibProvider.schemaSourceUnregistered(yangUnregistererSource);
    verify(dataBroker).newWriteOnlyTransaction();
    verify(writeTransaction).delete(eq(LogicalDatastoreType.OPERATIONAL), eq(InstanceIdentifier.create(ModulesState.class).child(Module.class, new ModuleKey(new YangIdentifier("unregistered-yang-schema-without-revision"), RevisionUtils.emptyRevision()))));
    verify(writeTransaction).commit();
    yangUnregistererSource = PotentialSchemaSource.create(RevisionSourceIdentifier.create("unregistered-yang-with-revision", org.opendaylight.yangtools.yang.common.Revision.of("2016-04-28")), YangTextSchemaSource.class, PotentialSchemaSource.Costs.LOCAL_IO.getValue());
    yangLibProvider.schemaSourceUnregistered(yangUnregistererSource);
    verify(dataBroker, times(2)).newWriteOnlyTransaction();
    verify(writeTransaction).delete(eq(LogicalDatastoreType.OPERATIONAL), eq(InstanceIdentifier.create(ModulesState.class).child(Module.class, new ModuleKey(new YangIdentifier("unregistered-yang-with-revision"), new Revision(new RevisionIdentifier("2016-04-28"))))));
    verify(writeTransaction, times(2)).commit();
}
Also used : ModulesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesState) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) Revision(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RevisionIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier) ModuleKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleKey) YangIdentifier(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 YangIdentifier (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier)4 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)3 RevisionIdentifier (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier)2 RevisionIdentifier (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.RevisionIdentifier)2 Revision (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.CommonLeafs.Revision)2 ModuleKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleKey)2 YangTextSchemaSource (org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Revision (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision)1 ModulesState (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesState)1 ModulesStateBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.ModulesStateBuilder)1 Module (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.Module)1 ModuleBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160621.module.list.ModuleBuilder)1 RevisionIdentifier (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.RevisionIdentifier)1 YangLibraryBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibraryBuilder)1 Module (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.Module)1 ModuleBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.ModuleBuilder)1 Submodule (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.set.parameters.module.Submodule)1