use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase in project lispflowmapping by opendaylight.
the class DataStoreBackEnd method getAllAuthenticationKeys.
public List<AuthenticationKey> getAllAuthenticationKeys() {
LOG.debug("MD-SAL: Get all authentication keys from datastore");
List<AuthenticationKey> authKeys = new ArrayList<AuthenticationKey>();
MappingDatabase mdb = readTransaction(DATABASE_ROOT, LogicalDatastoreType.CONFIGURATION);
if (mdb != null && mdb.getVirtualNetworkIdentifier() != null) {
for (VirtualNetworkIdentifier id : mdb.getVirtualNetworkIdentifier()) {
List<AuthenticationKey> keys = id.getAuthenticationKey();
if (keys != null) {
authKeys.addAll(keys);
}
}
}
return authKeys;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase in project lispflowmapping by opendaylight.
the class DataStoreBackEnd method getAllMappings.
public List<Mapping> getAllMappings(LogicalDatastoreType logicalDataStore) {
LOG.debug("MD-SAL: Get all mappings from {} datastore", logicalDataStore == LogicalDatastoreType.CONFIGURATION ? "config" : "operational");
List<Mapping> mappings = new ArrayList<Mapping>();
MappingDatabase mdb = readTransaction(DATABASE_ROOT, logicalDataStore);
if (mdb != null && mdb.getVirtualNetworkIdentifier() != null) {
for (VirtualNetworkIdentifier id : mdb.getVirtualNetworkIdentifier()) {
List<Mapping> ms = id.getMapping();
if (ms != null) {
mappings.addAll(ms);
}
}
}
return mappings;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase in project lispflowmapping by opendaylight.
the class DataStoreBackEndTest method getAllMappingsTest.
/**
* Tests {@link DataStoreBackEnd#getAllMappings} method.
*/
@Test
@SuppressWarnings("unchecked")
public void getAllMappingsTest() throws ReadFailedException {
final ReadOnlyTransaction rTxMock = Mockito.mock(ReadOnlyTransaction.class);
final CheckedFuture<Optional<MappingDatabase>, ReadFailedException> readFutureMock = Mockito.mock(CheckedFuture.class);
final Optional<MappingDatabase> optionalMock = Mockito.mock(Optional.class);
Mockito.when(txChainMock.newReadOnlyTransaction()).thenReturn(rTxMock);
Mockito.when(rTxMock.read(LogicalDatastoreType.CONFIGURATION, DATABASE_ROOT)).thenReturn(readFutureMock);
Mockito.when(rTxMock.read(LogicalDatastoreType.OPERATIONAL, DATABASE_ROOT)).thenReturn(readFutureMock);
Mockito.when(readFutureMock.checkedGet()).thenReturn(optionalMock);
Mockito.when(optionalMock.isPresent()).thenReturn(true);
Mockito.when(optionalMock.get()).thenReturn(getDefaultMappingDatabase().build());
assertEquals(8, dataStoreBackEnd.getAllMappings().size());
Mockito.verify(optionalMock, Mockito.times(2)).get();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase in project lispflowmapping by opendaylight.
the class DataStoreBackEndTest method getAllAuthenticationKeysTest.
/**
* Tests {@link DataStoreBackEnd#getAllAuthenticationKeys} method.
*/
@Test
@SuppressWarnings("unchecked")
public void getAllAuthenticationKeysTest() throws ReadFailedException {
final ReadOnlyTransaction rTxMock = Mockito.mock(ReadOnlyTransaction.class);
final CheckedFuture<Optional<MappingDatabase>, ReadFailedException> readFutureMock = Mockito.mock(CheckedFuture.class);
final Optional<MappingDatabase> optionalMock = Mockito.mock(Optional.class);
Mockito.when(txChainMock.newReadOnlyTransaction()).thenReturn(rTxMock);
Mockito.when(rTxMock.read(LogicalDatastoreType.CONFIGURATION, DATABASE_ROOT)).thenReturn(readFutureMock);
Mockito.when(readFutureMock.checkedGet()).thenReturn(optionalMock);
Mockito.when(optionalMock.isPresent()).thenReturn(true);
Mockito.when(optionalMock.get()).thenReturn(getDefaultMappingDatabase().build());
assertEquals(4, dataStoreBackEnd.getAllAuthenticationKeys().size());
Mockito.verify(optionalMock).get();
}
Aggregations