public void createTransactInvokers() {
if (transactInvokers == null) {
try {
- transactInvokers = new HashMap<DatabaseSchema,TransactInvoker>();
+ transactInvokers = new HashMap<>();
List<String> databases = getDatabases().get();
for (String database : databases) {
DatabaseSchema dbSchema = getSchema(database).get();
private void registerListener(final DataBroker db) {
final DataTreeIdentifier<Node> treeId =
- new DataTreeIdentifier<Node>(LogicalDatastoreType.CONFIGURATION, getWildcardPath());
+ new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildcardPath());
try {
LOG.trace("Registering on path: {}", treeId);
registration = db.registerDataTreeChangeListener(treeId, HwvtepDataChangeListener.this);
public class HwvtepOperationalCommandAggregator implements TransactionCommand {
- private List<TransactionCommand> commands = new ArrayList<TransactionCommand>();
+ private List<TransactionCommand> commands = new ArrayList<>();
public HwvtepOperationalCommandAggregator(HwvtepConnectionInstance key,TableUpdates updates,
DatabaseSchema dbSchema) {
private static final int QUEUE_SIZE = 10000;
private BindingTransactionChain chain;
private DataBroker db;
- private BlockingQueue<TransactionCommand> inputQueue = new LinkedBlockingQueue<TransactionCommand>(QUEUE_SIZE);
+ private BlockingQueue<TransactionCommand> inputQueue = new LinkedBlockingQueue<>(QUEUE_SIZE);
private BlockingQueue<ReadWriteTransaction> successfulTransactionQueue
- = new LinkedBlockingQueue<ReadWriteTransaction>(QUEUE_SIZE);
+ = new LinkedBlockingQueue<>(QUEUE_SIZE);
private BlockingQueue<AsyncTransaction<?, ?>> failedTransactionQueue
- = new LinkedBlockingQueue<AsyncTransaction<?, ?>>(QUEUE_SIZE);
+ = new LinkedBlockingQueue<>(QUEUE_SIZE);
private ExecutorService executor;
private Map<ReadWriteTransaction,TransactionCommand> transactionToCommand
- = new HashMap<ReadWriteTransaction,TransactionCommand>();
- private List<ReadWriteTransaction> pendingTransactions = new ArrayList<ReadWriteTransaction>();
+ = new HashMap<>();
+ private List<ReadWriteTransaction> pendingTransactions = new ArrayList<>();
public TransactionInvokerImpl(DataBroker db) {
this.db = db;
private List<TransactionCommand> extractResubmitCommands() {
AsyncTransaction<?, ?> transaction = failedTransactionQueue.poll();
- List<TransactionCommand> commands = new ArrayList<TransactionCommand>();
+ List<TransactionCommand> commands = new ArrayList<>();
if (transaction != null) {
int index = pendingTransactions.lastIndexOf(transaction);
List<ReadWriteTransaction> transactions =
private void resetTransactionQueue() {
chain.close();
chain = db.createTransactionChain(this);
- pendingTransactions = new ArrayList<ReadWriteTransaction>();
- transactionToCommand = new HashMap<ReadWriteTransaction,TransactionCommand>();
+ pendingTransactions = new ArrayList<>();
+ transactionToCommand = new HashMap<>();
failedTransactionQueue.clear();
successfulTransactionQueue.clear();
}
}
private List<TransactionCommand> extractCommandsFromQueue() throws InterruptedException {
- List<TransactionCommand> result = new ArrayList<TransactionCommand>();
+ List<TransactionCommand> result = new ArrayList<>();
TransactionCommand command = inputQueue.take();
while (command != null) {
result.add(command);
}
public void addRow(UUID uuid, Row<E> oldRow, Row<E> newRow) {
- rows.put(uuid, new RowUpdate<E>(uuid, oldRow, newRow));
+ rows.put(uuid, new RowUpdate<>(uuid, oldRow, newRow));
}
public Row<E> getOld(UUID uuid) {
}
public static <K,V> OvsdbMap<K,V> fromMap(Map<K, V> value) {
- return new OvsdbMap<K,V>(value);
+ return new OvsdbMap<>(value);
}
}
// When the row is null, that might indicate that the user maybe interested
// only in the ColumnSchema and not on the Data.
if (row == null) {
- return new Column<GenericTableSchema, Object>(columnSchema, null);
+ return new Column<>(columnSchema, null);
}
return row.getColumn(columnSchema);
}
}
private List<ProtocolEntry> createMdsalProtocols() {
- List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
+ List<ProtocolEntry> protocolList = new ArrayList<>();
ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
SouthboundConstants.OVSDB_PROTOCOL_MAP.inverse();
protocolList.add(new ProtocolEntryBuilder().
}
public static Set<String> createOvsdbBridgeProtocols(OvsdbBridgeAugmentation ovsdbBridgeNode) {
- Set<String> protocols = new HashSet<String>();
+ Set<String> protocols = new HashSet<>();
if (ovsdbBridgeNode.getProtocolEntry() != null && ovsdbBridgeNode.getProtocolEntry().size() > 0) {
for (ProtocolEntry protocol : ovsdbBridgeNode.getProtocolEntry()) {
if (SouthboundConstants.OVSDB_PROTOCOL_MAP.get(protocol.getProtocol()) != null) {
public class ConfigActivator implements BundleActivator {
private static final Logger LOG = LoggerFactory.getLogger(ConfigActivator.class);
- private List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
+ private List<ServiceRegistration<?>> registrations = new ArrayList<>();
private ProviderContext providerContext;
public ConfigActivator(ProviderContext providerContext) {
public Arp() {
payload = null;
- hdrFieldsMap = new HashMap<String, byte[]>(ARP_FIELDS_COUNT);
+ hdrFieldsMap = new HashMap<>(ARP_FIELDS_COUNT);
setHardwareLength((short) 6); // MAC address length
setProtocolLength((short) 4); // IPv4 address length
setHardwareType(ETHERNET_HW_TYPE);
private Neutron_IPs neutron_ip_src;
private Neutron_IPs neutron_ip_dest_1;
private Neutron_IPs neutron_ip_dest_2;
- private List<Neutron_IPs> neutronSrcIpList = new ArrayList<Neutron_IPs>();
- private List<Neutron_IPs> neutronDestIpList = new ArrayList<Neutron_IPs>();
+ private List<Neutron_IPs> neutronSrcIpList = new ArrayList<>();
+ private List<Neutron_IPs> neutronDestIpList = new ArrayList<>();
private static final String HOST_ADDRESS = "127.0.0.1/32";
private static final String MAC_ADDRESS = "87:1D:5E:02:40:B7";
private static final String SRC_IP = "192.168.0.1";
when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPv4");
when(portSecurityRule.getSecurityRuleDirection()).thenReturn("egress");
- List<NeutronSecurityRule> portSecurityList = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
portSecurityList.add(portSecurityRule);
neutron_ip_src = new Neutron_IPs();
@Mock private SecurityServicesManager securityServices;
@Mock private SecurityGroupCacheManger securityGroupCacheManger;
- private List<Neutron_IPs> neutronSrcIpList = new ArrayList<Neutron_IPs>();
- private List<Neutron_IPs> neutronDestIpList = new ArrayList<Neutron_IPs>();
+ private List<Neutron_IPs> neutronSrcIpList = new ArrayList<>();
+ private List<Neutron_IPs> neutronDestIpList = new ArrayList<>();
private Neutron_IPs neutron_ip_src;
private Neutron_IPs neutron_ip_dest_1;
private Neutron_IPs neutron_ip_dest_2;
when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPv4");
when(portSecurityRule.getSecurityRuleDirection()).thenReturn("ingress");
- List<NeutronSecurityRule> portSecurityList = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
portSecurityList.add(portSecurityRule);
neutron_ip_src = new Neutron_IPs();
public class ConfigActivator implements BundleActivator {
private static final Logger LOG = LoggerFactory.getLogger(ConfigActivator.class);
- private List<ServiceRegistration<?>> translatorCRUDRegistrations = new ArrayList<ServiceRegistration<?>>();
+ private List<ServiceRegistration<?>> translatorCRUDRegistrations = new ArrayList<>();
private List<Pair<Object, ServiceRegistration>> servicesAndRegistrations = new ArrayList<>();
private ProviderContext providerContext;
List<NeutronNetwork> allNetworks = neutronNetworkCache.getAllNetworks();
for (NeutronNetwork network: allNetworks) {
if (network.getID().equals(networkID)) {
- Map.Entry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(
+ Map.Entry<String,String> entry = new AbstractMap.SimpleEntry<>(
network.getProviderNetworkType(), network.getProviderSegmentationID());
return entry;
}
@Override
public List<NeutronSecurityGroup> getSecurityGroupInPortList(OvsdbTerminationPointAugmentation
terminationPointAugmentation) {
- List<NeutronSecurityGroup> neutronSecurityGroups = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> neutronSecurityGroups = new ArrayList<>();
if (neutronPortCache == null) {
LOG.error("neutron port is null");
return neutronSecurityGroups;
@Override
public List<Neutron_IPs> getVmListForSecurityGroup(String portUuid, String securityGroupUuid) {
- List<Neutron_IPs> vmListForSecurityGroup = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> vmListForSecurityGroup = new ArrayList<>();
/*For every port check whether security grouplist contains the current
* security group.*/
try {
}
private List<ProtocolEntry> createMdsalProtocols() {
- List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
+ List<ProtocolEntry> protocolList = new ArrayList<>();
ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
MdsalHelper.OVSDB_PROTOCOL_MAP.inverse();
protocolList.add(new ProtocolEntryBuilder().
}
public List<Node> getAllBridgesOnOvsdbNode(Node node) {
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
List<ManagedNodeEntry> managedNodes = node.getAugmentation(OvsdbNodeAugmentation.class).getManagedNodeEntry();
for (ManagedNodeEntry managedNode : managedNodes) {
InstanceIdentifier<?> bridgeIid = managedNode.getBridgeRef().getValue();
}
public List<TerminationPoint> extractTerminationPoints(Node node) {
- List<TerminationPoint> terminationPoints = new ArrayList<TerminationPoint>();
+ List<TerminationPoint> terminationPoints = new ArrayList<>();
OvsdbBridgeAugmentation ovsdbBridgeAugmentation = node.getAugmentation(OvsdbBridgeAugmentation.class);
if (ovsdbBridgeAugmentation != null) {
terminationPoints.addAll(node.getTerminationPoint());
}
public List<OvsdbTerminationPointAugmentation> extractTerminationPointAugmentations( Node node ) {
- List<OvsdbTerminationPointAugmentation> tpAugmentations = new ArrayList<OvsdbTerminationPointAugmentation>();
+ List<OvsdbTerminationPointAugmentation> tpAugmentations = new ArrayList<>();
List<TerminationPoint> terminationPoints = node.getTerminationPoint();
if(terminationPoints != null && !terminationPoints.isEmpty()){
for(TerminationPoint tp : terminationPoints){
if(operNode != null){
return extractTerminationPointAugmentations(operNode);
}
- return new ArrayList<OvsdbTerminationPointAugmentation>();
+ return new ArrayList<>();
}
public String getInterfaceExternalIdsValue(
tpAugmentationBuilder.setInterfaceType(MdsalHelper.OVSDB_INTERFACE_TYPE_MAP.get(type));
}
- List<Options> optionsList = new ArrayList<Options>();
+ List<Options> optionsList = new ArrayList<>();
for (Map.Entry<String, String> entry : options.entrySet()) {
OptionsBuilder optionsBuilder = new OptionsBuilder();
optionsBuilder.setKey(new OptionsKey(entry.getKey()));
}
public Boolean addPatchTerminationPoint(Node node, String bridgeName, String portName, String peerPortName) {
- Map<String, String> option = new HashMap<String, String>();
+ Map<String, String> option = new HashMap<>();
option.put("peer", peerPortName);
return addTerminationPoint(node, bridgeName, portName, PATCH_PORT_TYPE, option);
}
ans.setFirewallPolicyIsShared(firewallPolicyIsShared);
}
if (s.equals("firewall_rules")) {
- List<String> firewallRuleList = new ArrayList<String>();
+ List<String> firewallRuleList = new ArrayList<>();
firewallRuleList.addAll(this.getFirewallPolicyRules());
ans.setFirewallPolicyRules(firewallRuleList);
}
}
public void initDefaults() {
- subnets = new ArrayList<String>();
+ subnets = new ArrayList<>();
if (status == null) {
status = "ACTIVE";
}
ans.setStatus(this.getStatus());
}
if (s.equals("subnets")) {
- List<String> subnetList = new ArrayList<String>();
+ List<String> subnetList = new ArrayList<>();
subnetList.addAll(this.getSubnets());
ans.setSubnets(subnetList);
}
ans.setMacAddress(this.getMacAddress());
}
if ("fixed_ips".equals(field)) {
- ans.setFixedIPs(new ArrayList<Neutron_IPs>(this.getFixedIPs()));
+ ans.setFixedIPs(new ArrayList<>(this.getFixedIPs()));
}
if ("device_id".equals(field)) {
ans.setDeviceID(this.getDeviceID());
ans.setTenantID(this.getTenantID());
}
if ("security_groups".equals(field)) {
- ans.setSecurityGroups(new ArrayList<NeutronSecurityGroup>(this.getSecurityGroups()));
+ ans.setSecurityGroups(new ArrayList<>(this.getSecurityGroups()));
}
}
return ans;
status = "ACTIVE";
}
if (fixedIPs == null) {
- fixedIPs = new ArrayList<Neutron_IPs>();
+ fixedIPs = new ArrayList<>();
}
}
Map<String, NeutronRouter_Interface> interfaces;
public NeutronRouter() {
- interfaces = new HashMap<String, NeutronRouter_Interface>();
+ interfaces = new HashMap<>();
}
public String getID() { return routerUUID; }
List<NeutronSecurityRule> neutronSecurityRule;
public NeutronSecurityGroup() {
- neutronSecurityRule = new ArrayList<NeutronSecurityRule>();
+ neutronSecurityRule = new ArrayList<>();
}
List<NeutronPort> myPorts;
public NeutronSubnet() {
- myPorts = new ArrayList<NeutronPort>();
+ myPorts = new ArrayList<>();
}
// @deprecated - will be removed in Boron
ans.setGatewayIP(this.getGatewayIP());
}
if (s.equals("dns_nameservers")) {
- List<String> nsList = new ArrayList<String>();
+ List<String> nsList = new ArrayList<>();
nsList.addAll(this.getDnsNameservers());
ans.setDnsNameservers(nsList);
}
if (s.equals("allocation_pools")) {
- List<NeutronSubnetIPAllocationPool> aPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> aPools = new ArrayList<>();
aPools.addAll(this.getAllocationPools());
ans.setAllocationPools(aPools);
}
if (s.equals("host_routes")) {
- List<NeutronSubnet_HostRoute> hRoutes = new ArrayList<NeutronSubnet_HostRoute>();
+ List<NeutronSubnet_HostRoute> hRoutes = new ArrayList<>();
hRoutes.addAll(this.getHostRoutes());
ans.setHostRoutes(hRoutes);
}
// @deprecated - will be removed in Boron
public List<NeutronPort> getPortsInSubnet(String ignore) {
- List<NeutronPort> answer = new ArrayList<NeutronPort>();
+ List<NeutronPort> answer = new ArrayList<>();
for (NeutronPort port : myPorts) {
if (!port.getDeviceOwner().equalsIgnoreCase(ignore)) {
answer.add(port);
if (ipVersion == null) {
ipVersion = IPV4_VERSION;
}
- dnsNameservers = new ArrayList<String>();
+ dnsNameservers = new ArrayList<>();
if (hostRoutes == null) {
- hostRoutes = new ArrayList<NeutronSubnet_HostRoute>();
+ hostRoutes = new ArrayList<>();
}
if (allocationPools == null) {
- allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ allocationPools = new ArrayList<>();
if (ipVersion == IPV4_VERSION) {
try {
SubnetUtils util = new SubnetUtils(cidr);
* the other ranging from parameter+1 to high
*/
public List<NeutronSubnetIPAllocationPool> splitPool(String ipAddress) {
- List<NeutronSubnetIPAllocationPool> ans = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> ans = new ArrayList<>();
long gIP = NeutronSubnetIPAllocationPool.convert(ipAddress);
long sIP = NeutronSubnetIPAllocationPool.convert(poolStart);
long eIP = NeutronSubnetIPAllocationPool.convert(poolEnd);
* If the pool is a single address, return null
*/
public List<NeutronSubnetIPAllocationPool> splitPoolV6(String ipAddress) {
- List<NeutronSubnetIPAllocationPool> ans = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> ans = new ArrayList<>();
BigInteger gIP = NeutronSubnetIPAllocationPool.convertV6(ipAddress);
BigInteger sIP = NeutronSubnetIPAllocationPool.convertV6(poolStart);
BigInteger eIP = NeutronSubnetIPAllocationPool.convertV6(poolEnd);
@Override
public List<NeutronFloatingIP> getAllFloatingIPs() {
- Set<NeutronFloatingIP> allIPs = new HashSet<NeutronFloatingIP>();
+ Set<NeutronFloatingIP> allIPs = new HashSet<>();
Floatingips fips = readMd(createInstanceIdentifier());
if (fips != null) {
for (Floatingip fip: fips.getFloatingip()) {
}
}
LOGGER.debug("Exiting getAllFloatingIPs, Found {} FloatingIPs", allIPs.size());
- List<NeutronFloatingIP> ans = new ArrayList<NeutronFloatingIP>();
+ List<NeutronFloatingIP> ans = new ArrayList<>();
ans.addAll(allIPs);
return ans;
}
*/
public class NeutronLoadBalancerInterface extends AbstractNeutronInterface<Loadbalancer, NeutronLoadBalancer> implements INeutronLoadBalancerCRUD {
private static final Logger LOGGER = LoggerFactory.getLogger(NeutronLoadBalancerInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancer> loadBalancerDB = new ConcurrentHashMap<String, NeutronLoadBalancer>();
+ private ConcurrentMap<String, NeutronLoadBalancer> loadBalancerDB = new ConcurrentHashMap<>();
NeutronLoadBalancerInterface(ProviderContext providerContext) {
@Override
public List<NeutronLoadBalancer> getAllNeutronLoadBalancers() {
- Set<NeutronLoadBalancer> allLoadBalancers = new HashSet<NeutronLoadBalancer>();
+ Set<NeutronLoadBalancer> allLoadBalancers = new HashSet<>();
for (Entry<String, NeutronLoadBalancer> entry : loadBalancerDB.entrySet()) {
NeutronLoadBalancer loadBalancer = entry.getValue();
allLoadBalancers.add(loadBalancer);
}
LOGGER.debug("Exiting getLoadBalancers, Found {} OpenStackLoadBalancer", allLoadBalancers.size());
- List<NeutronLoadBalancer> ans = new ArrayList<NeutronLoadBalancer>();
+ List<NeutronLoadBalancer> ans = new ArrayList<>();
ans.addAll(allLoadBalancers);
return ans;
}
public class NeutronLoadBalancerPoolInterface extends AbstractNeutronInterface<Pool, NeutronLoadBalancerPool> implements INeutronLoadBalancerPoolCRUD {
private static final Logger LOGGER = LoggerFactory.getLogger(NeutronLoadBalancerPoolInterface.class);
- private ConcurrentMap<String, NeutronLoadBalancerPool> loadBalancerPoolDB = new ConcurrentHashMap<String, NeutronLoadBalancerPool>();
+ private ConcurrentMap<String, NeutronLoadBalancerPool> loadBalancerPoolDB = new ConcurrentHashMap<>();
private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
= new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
@Override
public List<NeutronLoadBalancerPool> getAllNeutronLoadBalancerPools() {
- Set<NeutronLoadBalancerPool> allLoadBalancerPools = new HashSet<NeutronLoadBalancerPool>();
+ Set<NeutronLoadBalancerPool> allLoadBalancerPools = new HashSet<>();
for (Entry<String, NeutronLoadBalancerPool> entry : loadBalancerPoolDB.entrySet()) {
NeutronLoadBalancerPool loadBalancerPool = entry.getValue();
allLoadBalancerPools.add(loadBalancerPool);
}
LOGGER.debug("Exiting getLoadBalancerPools, Found {} OpenStackLoadBalancerPool", allLoadBalancerPools.size());
- List<NeutronLoadBalancerPool> ans = new ArrayList<NeutronLoadBalancerPool>();
+ List<NeutronLoadBalancerPool> ans = new ArrayList<>();
ans.addAll(allLoadBalancerPools);
return ans;
}
poolBuilder.setLbAlgorithm(pool.getLoadBalancerPoolLbAlgorithm());
}
if (pool.getLoadBalancerPoolListeners() != null) {
- List<Uuid> listListener = new ArrayList<Uuid>();
+ List<Uuid> listListener = new ArrayList<>();
for (Neutron_ID neutron_id : pool.getLoadBalancerPoolListeners()) {
listListener.add(toUuid(neutron_id.getID()));
}
@Override
public List<NeutronNetwork> getAllNetworks() {
- Set<NeutronNetwork> allNetworks = new HashSet<NeutronNetwork>();
+ Set<NeutronNetwork> allNetworks = new HashSet<>();
Networks networks = readMd(createInstanceIdentifier());
if (networks != null) {
for (Network network: networks.getNetwork()) {
}
}
LOGGER.debug("Exiting getAllNetworks, Found {} OpenStackNetworks", allNetworks.size());
- List<NeutronNetwork> ans = new ArrayList<NeutronNetwork>();
+ List<NeutronNetwork> ans = new ArrayList<>();
ans.addAll(allNetworks);
return ans;
}
result.setShared(network.isShared());
result.setStatus(network.getStatus());
if (network.getSubnets() != null) {
- List<String> neutronSubnets = new ArrayList<String>();
+ List<String> neutronSubnets = new ArrayList<>();
for( Uuid subnet : network.getSubnets()) {
neutronSubnets.add(subnet.getValue());
}
result.setProviderPhysicalNetwork(providerExtension.getPhysicalNetwork());
result.setProviderSegmentationID(providerExtension.getSegmentationId());
result.setProviderNetworkType(NETWORK_MAP.get(providerExtension.getNetworkType()));
- List<NeutronNetwork_Segment> segments = new ArrayList<NeutronNetwork_Segment>();
+ List<NeutronNetwork_Segment> segments = new ArrayList<>();
if (providerExtension.getSegments() != null) {
for (Segments segment: providerExtension.getSegments()) {
NeutronNetwork_Segment neutronSegment = new NeutronNetwork_Segment();
providerExtensionBuilder.setNetworkType((Class<? extends NetworkTypeBase>) mapper.get(network.getProviderNetworkType()));
}
if (network.getSegments() != null) {
- List<Segments> segments = new ArrayList<Segments>();
+ List<Segments> segments = new ArrayList<>();
long count = 0;
for( NeutronNetwork_Segment segment : network.getSegments()) {
count++;
networkBuilder.setStatus(network.getStatus());
}
if (network.getSubnets() != null) {
- List<Uuid> subnets = new ArrayList<Uuid>();
+ List<Uuid> subnets = new ArrayList<>();
for( String subnet : network.getSubnets()) {
subnets.add(toUuid(subnet));
}
@Override
public List<NeutronPort> getAllPorts() {
- Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ Set<NeutronPort> allPorts = new HashSet<>();
Ports ports = readMd(createInstanceIdentifier());
if (ports != null) {
for (Port port : ports.getPort()) {
}
}
LOGGER.debug("Exiting getAllPorts, Found {} OpenStackPorts", allPorts.size());
- List<NeutronPort> ans = new ArrayList<NeutronPort>();
+ List<NeutronPort> ans = new ArrayList<>();
ans.addAll(allPorts);
return ans;
}
PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
result.setBindinghostID(binding.getHostId());
if (binding.getVifDetails() != null) {
- List<NeutronPort_VIFDetail> details = new ArrayList<NeutronPort_VIFDetail>();
+ List<NeutronPort_VIFDetail> details = new ArrayList<>();
for (VifDetails vifDetail : binding.getVifDetails()) {
NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
detail.setPortFilter(vifDetail.isPortFilter());
NeutronPort result = new NeutronPort();
result.setAdminStateUp(port.isAdminStateUp());
if (port.getAllowedAddressPairs() != null) {
- List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<NeutronPort_AllowedAddressPairs>();
+ List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<>();
for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
pair.setIpAddress(mdPair.getIpAddress());
result.setDeviceID(port.getDeviceId());
result.setDeviceOwner(port.getDeviceOwner());
if (port.getExtraDhcpOpts() != null) {
- List<NeutronPort_ExtraDHCPOption> options = new ArrayList<NeutronPort_ExtraDHCPOption>();
+ List<NeutronPort_ExtraDHCPOption> options = new ArrayList<>();
for (ExtraDhcpOpts opt : port.getExtraDhcpOpts()) {
NeutronPort_ExtraDHCPOption arg = new NeutronPort_ExtraDHCPOption();
arg.setName(opt.getOptName());
result.setExtraDHCPOptions(options);
}
if (port.getFixedIps() != null) {
- List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> ips = new ArrayList<>();
for (FixedIps mdIP : port.getFixedIps()) {
Neutron_IPs ip = new Neutron_IPs();
ip.setIpAddress(String.valueOf(mdIP.getIpAddress().getValue()));
result.setName(port.getName());
result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
if (port.getSecurityGroups() != null) {
- Set<NeutronSecurityGroup> allGroups = new HashSet<NeutronSecurityGroup>();
+ Set<NeutronSecurityGroup> allGroups = new HashSet<>();
NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this);
INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface();
for (Uuid sgUuid : port.getSecurityGroups()) {
allGroups.add(sgIf.getNeutronSecurityGroup(sgUuid.getValue()));
}
- List<NeutronSecurityGroup> groups = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> groups = new ArrayList<>();
groups.addAll(allGroups);
result.setSecurityGroups(groups);
}
bindingBuilder.setHostId(neutronPort.getBindinghostID());
}
if (neutronPort.getVIFDetail() != null) {
- List<VifDetails> listVifDetail = new ArrayList<VifDetails>();
+ List<VifDetails> listVifDetail = new ArrayList<>();
for (NeutronPort_VIFDetail detail: neutronPort.getVIFDetail()) {
VifDetailsBuilder vifDetailsBuilder = new VifDetailsBuilder();
if (detail.getPortFilter() != null) {
bindingBuilder.build());
portBuilder.setAdminStateUp(neutronPort.isAdminStateUp());
if(neutronPort.getAllowedAddressPairs() != null) {
- List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<AllowedAddressPairs>();
+ List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<>();
for (NeutronPort_AllowedAddressPairs allowedAddressPairs : neutronPort.getAllowedAddressPairs()) {
AllowedAddressPairsBuilder allowedAddressPairsBuilder = new AllowedAddressPairsBuilder();
allowedAddressPairsBuilder.setIpAddress(allowedAddressPairs.getIpAddress());
portBuilder.setDeviceOwner(neutronPort.getDeviceOwner());
}
if (neutronPort.getExtraDHCPOptions() != null) {
- List<ExtraDhcpOpts> listExtraDHCPOptions = new ArrayList<ExtraDhcpOpts>();
+ List<ExtraDhcpOpts> listExtraDHCPOptions = new ArrayList<>();
for (NeutronPort_ExtraDHCPOption extraDHCPOption : neutronPort.getExtraDHCPOptions()) {
ExtraDhcpOptsBuilder extraDHCPOptsBuilder = new ExtraDhcpOptsBuilder();
extraDHCPOptsBuilder.setOptName(extraDHCPOption.getName());
portBuilder.setExtraDhcpOpts(listExtraDHCPOptions);
}
if (neutronPort.getFixedIPs() != null) {
- List<FixedIps> listNeutronIPs = new ArrayList<FixedIps>();
+ List<FixedIps> listNeutronIPs = new ArrayList<>();
for (Neutron_IPs neutron_IPs : neutronPort.getFixedIPs()) {
FixedIpsBuilder fixedIpsBuilder = new FixedIpsBuilder();
fixedIpsBuilder.setIpAddress(new IpAddress(neutron_IPs.getIpAddress().toCharArray()));
portBuilder.setNetworkId(toUuid(neutronPort.getNetworkUUID()));
}
if (neutronPort.getSecurityGroups() != null) {
- List<Uuid> listSecurityGroups = new ArrayList<Uuid>();
+ List<Uuid> listSecurityGroups = new ArrayList<>();
for (NeutronSecurityGroup neutronSecurityGroup : neutronPort.getSecurityGroups()) {
listSecurityGroups.add(toUuid(neutronSecurityGroup.getID()));
}
@Override
public List<NeutronRouter> getAllRouters() {
- Set<NeutronRouter> allRouters = new HashSet<NeutronRouter>();
+ Set<NeutronRouter> allRouters = new HashSet<>();
Routers routers = readMd(createInstanceIdentifier());
if (routers != null) {
for (Router router: routers.getRouter()) {
}
}
LOGGER.debug("Exiting getAllRouters, Found {} Routers", allRouters.size());
- List<NeutronRouter> ans = new ArrayList<NeutronRouter>();
+ List<NeutronRouter> ans = new ArrayList<>();
ans.addAll(allRouters);
return ans;
}
routerBuilder.setAdminStateUp(router.getAdminStateUp());
routerBuilder.setDistributed(router.getDistributed());
if (router.getRoutes() != null) {
- List<String> routes = new ArrayList<String>();
+ List<String> routes = new ArrayList<>();
for (String route : router.getRoutes()) {
routes.add(route);
}
}
if (router.getExternalGatewayInfo() != null) {
ExternalGatewayInfo externalGatewayInfo = null;
- List<NeutronRouter_NetworkReference> neutronRouter_NetworkReferences = new ArrayList<NeutronRouter_NetworkReference>();
+ List<NeutronRouter_NetworkReference> neutronRouter_NetworkReferences = new ArrayList<>();
neutronRouter_NetworkReferences.add(router.getExternalGatewayInfo());
for (NeutronRouter_NetworkReference externalGatewayInfos : neutronRouter_NetworkReferences) {
ExternalGatewayInfoBuilder builder = new ExternalGatewayInfoBuilder();
builder.setEnableSnat(externalGatewayInfos.getEnableSNAT());
builder.setExternalNetworkId(toUuid(externalGatewayInfos.getNetworkID()));
if (externalGatewayInfos.getExternalFixedIPs() != null) {
- List<ExternalFixedIps> externalFixedIps = new ArrayList<ExternalFixedIps>();
+ List<ExternalFixedIps> externalFixedIps = new ArrayList<>();
for (Neutron_IPs eIP : externalGatewayInfos.getExternalFixedIPs()) {
ExternalFixedIpsBuilder eFixedIpBuilder = new ExternalFixedIpsBuilder();
eFixedIpBuilder.setIpAddress(new IpAddress(eIP.getIpAddress().toCharArray()));
routerBuilder.setExternalGatewayInfo(externalGatewayInfo);
}
if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> mapInterfaces = new HashMap<String, NeutronRouter_Interface>();
- List<Interfaces> interfaces = new ArrayList<Interfaces>();
+ Map<String, NeutronRouter_Interface> mapInterfaces = new HashMap<>();
+ List<Interfaces> interfaces = new ArrayList<>();
for (Entry<String, NeutronRouter_Interface> entry : mapInterfaces.entrySet()) {
interfaces.add((Interfaces) entry.getValue());
}
result.setGatewayPortId(String.valueOf(router.getGatewayPortId().getValue()));
}
if (router.getRoutes() != null) {
- List<String> routes = new ArrayList<String>();
+ List<String> routes = new ArrayList<>();
for (String route : router.getRoutes()) {
routes.add(route);
}
extGwInfo.setNetworkID(String.valueOf(router.getExternalGatewayInfo().getExternalNetworkId().getValue()));
extGwInfo.setEnableSNAT(router.getExternalGatewayInfo().isEnableSnat());
if (router.getExternalGatewayInfo().getExternalFixedIps() != null) {
- List<Neutron_IPs> fixedIPs = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> fixedIPs = new ArrayList<>();
for (ExternalFixedIps mdFixedIP : router.getExternalGatewayInfo().getExternalFixedIps()) {
Neutron_IPs fixedIP = new Neutron_IPs();
fixedIP.setSubnetUUID(String.valueOf(mdFixedIP.getSubnetId().getValue()));
}
if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> interfaces = new HashMap<String, NeutronRouter_Interface>();
+ Map<String, NeutronRouter_Interface> interfaces = new HashMap<>();
for (Interfaces mdInterface : router.getInterfaces()) {
NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
String id = String.valueOf(mdInterface.getUuid().getValue());
@Override
public List<NeutronSecurityGroup> getAllNeutronSecurityGroups() {
- Set<NeutronSecurityGroup> allSecurityGroups = new HashSet<NeutronSecurityGroup>();
+ Set<NeutronSecurityGroup> allSecurityGroups = new HashSet<>();
SecurityGroups groups = readMd(createInstanceIdentifier());
if (groups != null) {
for (SecurityGroup group: groups.getSecurityGroup()) {
}
}
LOGGER.debug("Exiting getSecurityGroups, Found {} OpenStackSecurityGroup", allSecurityGroups.size());
- List<NeutronSecurityGroup> ans = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> ans = new ArrayList<>();
ans.addAll(allSecurityGroups);
return ans;
}
.fetchINeutronSecurityRuleCRUD(this);
INeutronSecurityRuleCRUD srCrud = interfaces.getSecurityRuleInterface();
- List<NeutronSecurityRule> rules = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> rules = new ArrayList<>();
for (Uuid uuid: group.getSecurityRules()) {
rules.add(srCrud.getNeutronSecurityRule(uuid.getValue()));
}
securityGroupBuilder.setTenantId(toUuid(securityGroup.getSecurityGroupTenantID()));
}
if (securityGroup.getSecurityRules() != null) {
- List<Uuid> neutronSecurityRule = new ArrayList<Uuid>();
+ List<Uuid> neutronSecurityRule = new ArrayList<>();
for (NeutronSecurityRule securityRule : securityGroup.getSecurityRules()) {
if (securityRule.getID() != null) {
neutronSecurityRule.add(toUuid(securityRule.getID()));
INeutronSecurityGroupCRUD sgCrud = interfaces.getSecurityGroupInterface();
NeutronSecurityGroup sg = sgCrud.getNeutronSecurityGroup(input.getSecurityRuleGroupID());
if(sg != null && sg.getSecurityRules() != null) {
- List<NeutronSecurityRule> toRemove = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> toRemove = new ArrayList<>();
for(NeutronSecurityRule sgr :sg.getSecurityRules()) {
if(sgr.getID() != null && sgr.getID().equals(input.getID())) {
toRemove.add(sgr);
@Override
public List<NeutronSecurityRule> getAllNeutronSecurityRules() {
- Set<NeutronSecurityRule> allSecurityRules = new HashSet<NeutronSecurityRule>();
+ Set<NeutronSecurityRule> allSecurityRules = new HashSet<>();
SecurityRules rules = readMd(createInstanceIdentifier());
if (rules != null) {
for (SecurityRule rule: rules.getSecurityRule()) {
}
}
LOGGER.debug("Exiting getSecurityRule, Found {} OpenStackSecurityRule", allSecurityRules.size());
- List<NeutronSecurityRule> ans = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> ans = new ArrayList<>();
ans.addAll(allSecurityRules);
return ans;
}
@Override
public List<NeutronSubnet> getAllSubnets() {
- Set<NeutronSubnet> allSubnets = new HashSet<NeutronSubnet>();
+ Set<NeutronSubnet> allSubnets = new HashSet<>();
Subnets subnets = readMd(createInstanceIdentifier());
if (subnets != null) {
for (Subnet subnet: subnets.getSubnet()) {
}
}
LOGGER.debug("Exiting getAllSubnets, Found {} OpenStackSubnets", allSubnets.size());
- List<NeutronSubnet> ans = new ArrayList<NeutronSubnet>();
+ List<NeutronSubnet> ans = new ArrayList<>();
ans.addAll(allSubnets);
return ans;
}
result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
result.setEnableDHCP(subnet.isEnableDhcp());
if (subnet.getAllocationPools() != null) {
- List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<>();
for (AllocationPools allocationPool : subnet.getAllocationPools()) {
NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
pool.setPoolStart(allocationPool.getStart());
result.setAllocationPools(allocationPools);
}
if (subnet.getDnsNameservers() != null) {
- List<String> dnsNameServers = new ArrayList<String>();
+ List<String> dnsNameServers = new ArrayList<>();
for (IpAddress dnsNameServer : subnet.getDnsNameservers()) {
dnsNameServers.add(String.valueOf(dnsNameServer.getValue()));
}
// read through the ports and put the ones in this subnet into the internal
// myPorts object.
// @deprecated and will be removed in Boron
- Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ Set<NeutronPort> allPorts = new HashSet<>();
NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
.fetchINeutronPortCRUD(this);
INeutronPortCRUD portIf = interfaces.getPortInterface();
}
}
}
- List<NeutronPort> ports = new ArrayList<NeutronPort>();
+ List<NeutronPort> ports = new ArrayList<>();
ports.addAll(allPorts);
result.setPorts(ports);
return result;
}
subnetBuilder.setEnableDhcp(subnet.getEnableDHCP());
if (subnet.getAllocationPools() != null) {
- List<AllocationPools> allocationPools = new ArrayList<AllocationPools>();
+ List<AllocationPools> allocationPools = new ArrayList<>();
for (NeutronSubnetIPAllocationPool allocationPool : subnet
.getAllocationPools()) {
AllocationPoolsBuilder builder = new AllocationPoolsBuilder();
subnetBuilder.setAllocationPools(allocationPools);
}
if (subnet.getDnsNameservers() != null) {
- List<IpAddress> dnsNameServers = new ArrayList<IpAddress>();
+ List<IpAddress> dnsNameServers = new ArrayList<>();
for (String dnsNameServer : subnet.getDnsNameservers()) {
IpAddress ipAddress = new IpAddress(dnsNameServer.toCharArray());
dnsNameServers.add(ipAddress);
result.setShared(network.isShared());
result.setStatus(network.getStatus());
if (network.getSubnets() != null) {
- List<String> neutronSubnets = new ArrayList<String>();
+ List<String> neutronSubnets = new ArrayList<>();
for( Uuid subnet : network.getSubnets()) {
neutronSubnets.add(subnet.getValue());
}
result.setProviderPhysicalNetwork(providerExtension.getPhysicalNetwork());
result.setProviderSegmentationID(providerExtension.getSegmentationId());
result.setProviderNetworkType(NETWORK_MAP.get(providerExtension.getNetworkType()));
- List<NeutronNetwork_Segment> segments = new ArrayList<NeutronNetwork_Segment>();
+ List<NeutronNetwork_Segment> segments = new ArrayList<>();
if (providerExtension.getSegments() != null) {
for (Segments segment: providerExtension.getSegments()) {
NeutronNetwork_Segment neutronSegment = new NeutronNetwork_Segment();
NeutronPort result = new NeutronPort();
result.setAdminStateUp(port.isAdminStateUp());
if (port.getAllowedAddressPairs() != null) {
- List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<NeutronPort_AllowedAddressPairs>();
+ List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<>();
for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
pair.setIpAddress(mdPair.getIpAddress());
result.setDeviceID(port.getDeviceId());
result.setDeviceOwner(port.getDeviceOwner());
if (port.getExtraDhcpOpts() != null) {
- List<NeutronPort_ExtraDHCPOption> options = new ArrayList<NeutronPort_ExtraDHCPOption>();
+ List<NeutronPort_ExtraDHCPOption> options = new ArrayList<>();
for (ExtraDhcpOpts opt : port.getExtraDhcpOpts()) {
NeutronPort_ExtraDHCPOption arg = new NeutronPort_ExtraDHCPOption();
arg.setName(opt.getOptName());
result.setExtraDHCPOptions(options);
}
if (port.getFixedIps() != null) {
- List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> ips = new ArrayList<>();
for (FixedIps mdIP : port.getFixedIps()) {
Neutron_IPs ip = new Neutron_IPs();
ip.setIpAddress(String.valueOf(mdIP.getIpAddress().getValue()));
result.setName(port.getName());
result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
if (port.getSecurityGroups() != null) {
- Set<NeutronSecurityGroup> allGroups = new HashSet<NeutronSecurityGroup>();
+ Set<NeutronSecurityGroup> allGroups = new HashSet<>();
NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this);
INeutronSecurityGroupCRUD sgIf = interfaces.getSecurityGroupInterface();
for (Uuid sgUuid : port.getSecurityGroups()) {
allGroups.add(sgIf.getNeutronSecurityGroup(sgUuid.getValue()));
}
- List<NeutronSecurityGroup> groups = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> groups = new ArrayList<>();
groups.addAll(allGroups);
result.setSecurityGroups(groups);
}
PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
result.setBindinghostID(binding.getHostId());
if (binding.getVifDetails() != null) {
- List<NeutronPort_VIFDetail> details = new ArrayList<NeutronPort_VIFDetail>();
+ List<NeutronPort_VIFDetail> details = new ArrayList<>();
for (VifDetails vifDetail : binding.getVifDetails()) {
NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
detail.setPortFilter(vifDetail.isPortFilter());
private Map<String,NeutronPort> getChangedPorts(Map<InstanceIdentifier<?>, DataObject> changedData) {
LOG.trace("getChangedPorts:" + changedData);
- Map<String,NeutronPort> portMap = new HashMap<String,NeutronPort>();
+ Map<String,NeutronPort> portMap = new HashMap<>();
for (Map.Entry<InstanceIdentifier<?>, DataObject> changed : changedData.entrySet()) {
if (changed.getValue() instanceof Port) {
NeutronPort port = fromMd((Port)changed.getValue());
result.setGatewayPortId(String.valueOf(router.getGatewayPortId().getValue()));
}
if (router.getRoutes() != null) {
- List<String> routes = new ArrayList<String>();
+ List<String> routes = new ArrayList<>();
for (String route : router.getRoutes()) {
routes.add(route);
}
extGwInfo.setNetworkID(String.valueOf(router.getExternalGatewayInfo().getExternalNetworkId().getValue()));
extGwInfo.setEnableSNAT(router.getExternalGatewayInfo().isEnableSnat());
if (router.getExternalGatewayInfo().getExternalFixedIps() != null) {
- List<Neutron_IPs> fixedIPs = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> fixedIPs = new ArrayList<>();
for (ExternalFixedIps mdFixedIP : router.getExternalGatewayInfo().getExternalFixedIps()) {
Neutron_IPs fixedIP = new Neutron_IPs();
fixedIP.setSubnetUUID(String.valueOf(mdFixedIP.getSubnetId().getValue()));
}
if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> interfaces = new HashMap<String, NeutronRouter_Interface>();
+ Map<String, NeutronRouter_Interface> interfaces = new HashMap<>();
for (Interfaces mdInterface : router.getInterfaces()) {
NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
String id = String.valueOf(mdInterface.getUuid().getValue());
INeutronSecurityRuleCRUD srCrud = interfaces
.getSecurityRuleInterface();
- List<NeutronSecurityRule> rules = new ArrayList<NeutronSecurityRule>();
+ List<NeutronSecurityRule> rules = new ArrayList<>();
for (Uuid uuid : group.getSecurityRules()) {
rules.add(srCrud.getNeutronSecurityRule(uuid.getValue()));
}
result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
result.setEnableDHCP(subnet.isEnableDhcp());
if (subnet.getAllocationPools() != null) {
- List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
+ List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<>();
for (AllocationPools allocationPool : subnet.getAllocationPools()) {
NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
pool.setPoolStart(allocationPool.getStart());
result.setAllocationPools(allocationPools);
}
if (subnet.getDnsNameservers() != null) {
- List<String> dnsNameServers = new ArrayList<String>();
+ List<String> dnsNameServers = new ArrayList<>();
for (IpAddress dnsNameServer : subnet.getDnsNameservers()) {
dnsNameServers.add(String.valueOf(dnsNameServer.getValue()));
}
// read through the ports and put the ones in this subnet into the internal
// myPorts object.
- Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
+ Set<NeutronPort> allPorts = new HashSet<>();
NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
.fetchINeutronPortCRUD(this);
INeutronPortCRUD portIf = interfaces.getPortInterface();
}
}
}
- List<NeutronPort> ports = new ArrayList<NeutronPort>();
+ List<NeutronPort> ports = new ArrayList<>();
ports.addAll(allPorts);
result.setPorts(ports);
return result;
public void setUp() {
when(neutronLBPool.getLoadBalancerPoolProtocol()).thenReturn(LoadBalancerConfiguration.PROTOCOL_HTTP);
- List<NeutronLoadBalancerPoolMember> members = new ArrayList<NeutronLoadBalancerPoolMember>();
+ List<NeutronLoadBalancerPoolMember> members = new ArrayList<>();
NeutronLoadBalancerPoolMember neutronLBPoolMember = mock(NeutronLoadBalancerPoolMember.class);
when(neutronLBPoolMember.getPoolMemberAdminStateIsUp()).thenReturn(true);
when(neutronLBPoolMember.getPoolMemberSubnetID()).thenReturn("subnetID");
members.add(neutronLBPoolMember);
when(neutronLBPool.getLoadBalancerPoolMembers()).thenReturn(members);
- List<NeutronLoadBalancer> list_neutronLB = new ArrayList<NeutronLoadBalancer>();
+ List<NeutronLoadBalancer> list_neutronLB = new ArrayList<>();
NeutronLoadBalancer neutronLB = mock(NeutronLoadBalancer.class);
when(neutronLB.getLoadBalancerName()).thenReturn("load_balancer_name");
when(neutronLB.getLoadBalancerVipAddress()).thenReturn("vip_address");
NorthboundEvent ev = mock(NorthboundEvent.class);
when(ev.getLoadBalancerPool()).thenReturn(neutronLBPool);
- List<Node> list_node = new ArrayList<Node>();
+ List<Node> list_node = new ArrayList<>();
list_node .add(mock(Node.class));
when(nodeCacheManager.getBridgeNodes()).thenReturn(list_node);
when(NeutronCacheUtils.getMacAddress(any(INeutronPortCRUD.class), anyString(), anyString())).thenReturn("mac_address");
when(NeutronCacheUtils.getProviderInformation(any(INeutronNetworkCRUD.class), any(INeutronSubnetCRUD.class), anyString())).thenReturn(providerInfo);
- List<NeutronLoadBalancerPoolMember> members = new ArrayList<NeutronLoadBalancerPoolMember>();
+ List<NeutronLoadBalancerPoolMember> members = new ArrayList<>();
NeutronLoadBalancerPoolMember neutronLBPoolMember = mock(NeutronLoadBalancerPoolMember.class);
when(neutronLBPoolMember.getPoolMemberAdminStateIsUp()).thenReturn(true);
when(neutronLBPoolMember.getPoolMemberSubnetID()).thenReturn("subnetID");
when(neutronLBPool.getLoadBalancerPoolMembers()).thenReturn(members);
when(neutronLBPoolCache.getNeutronLoadBalancerPool(anyString())).thenReturn(neutronLBPool);
- List<NeutronLoadBalancer> list_neutronLB = new ArrayList<NeutronLoadBalancer>();
+ List<NeutronLoadBalancer> list_neutronLB = new ArrayList<>();
NeutronLoadBalancer neutronLB = mock(NeutronLoadBalancer.class);
when(neutronLB.getLoadBalancerName()).thenReturn("load_balancer_name");
when(neutronLB.getLoadBalancerVipAddress()).thenReturn("vip_address");
NorthboundEvent ev = mock(NorthboundEvent.class);
when(ev.getLoadBalancerPoolMember()).thenReturn(neutronLBMember);
- List<Node> list_node = new ArrayList<Node>();
+ List<Node> list_node = new ArrayList<>();
list_node .add(mock(Node.class));
when(nodeCacheManager.getBridgeNodes()).thenReturn(list_node);
Neutron_IPs ip = mock(Neutron_IPs.class);
when(ip.getIpAddress()).thenReturn("ip_address");
when(ip.getSubnetUUID()).thenReturn("subnetUUID");
- List<Neutron_IPs> list_fixedIP = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> list_fixedIP = new ArrayList<>();
list_fixedIP.add(ip);
when(port.getFixedIPs()).thenReturn(list_fixedIP);
when(port.getMacAddress()).thenReturn("mac_address");
- List<NeutronPort> list_port = new ArrayList<NeutronPort>();
+ List<NeutronPort> list_port = new ArrayList<>();
list_port.add(port);
when(neutronPortsCache.getAllPorts()).thenReturn(list_port);
NeutronSubnet subnet = mock(NeutronSubnet.class);
when(subnet.getID()).thenReturn("subnetUUID");
when(subnet.getNetworkUUID()).thenReturn("networkUUID");
- List<NeutronSubnet> list_subnet = new ArrayList<NeutronSubnet>();
+ List<NeutronSubnet> list_subnet = new ArrayList<>();
list_subnet.add(subnet);
when(neutronSubnetCache.getAllSubnets()).thenReturn(list_subnet );
when(network.getID()).thenReturn("networkUUID");
when(network.getProviderNetworkType()).thenReturn("network_type_1");
when(network.getProviderSegmentationID()).thenReturn("network_segID");
- List<NeutronNetwork> list_network = new ArrayList<NeutronNetwork>();
+ List<NeutronNetwork> list_network = new ArrayList<>();
list_network.add(network);
when(neutronNetworkCache.getAllNetworks()).thenReturn(list_network);
- Map.Entry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(
+ Map.Entry<String,String> entry = new AbstractMap.SimpleEntry<>(
network.getProviderNetworkType(), network.getProviderSegmentationID());
assertEquals("Error, getProviderInformation() did not return the correct values", entry, NeutronCacheUtils.getProviderInformation(neutronNetworkCache, neutronSubnetCache, "subnetUUID"));
portHandlerSpy.processEvent(ev);
verify(neutronL3Adapter, times(1)).handleNeutronPortEvent(neutronPort, Action.UPDATE);
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(mock(Node.class));
when(nodeCacheManager.getNodes()).thenReturn(nodes);
- List<OvsdbTerminationPointAugmentation> ports = new ArrayList<OvsdbTerminationPointAugmentation>();
+ List<OvsdbTerminationPointAugmentation> ports = new ArrayList<>();
OvsdbTerminationPointAugmentation port = mock(OvsdbTerminationPointAugmentation.class);
ports.add(port);
when(southbound.getTerminationPointsOfBridge(any(Node.class))).thenReturn(ports);
Node node = mock(Node.class);
when(node.getAugmentation(OvsdbNodeAugmentation.class)).thenReturn(mock(OvsdbNodeAugmentation.class));
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(mock(Node.class));
when(southbound.readOvsdbTopologyNodes()).thenReturn(nodes);
when(ev.getType()).thenReturn(Type.OPENVSWITCH);
when(ovsdbTerminationPointAugmentation.getName()).thenReturn("network");
- List<TerminationPoint> terminationPoints = new ArrayList<TerminationPoint>();
+ List<TerminationPoint> terminationPoints = new ArrayList<>();
terminationPoints.add(mock(TerminationPoint.class));
when(southbound.extractTerminationPoints(any(Node.class))).thenReturn(terminationPoints);
@Test
public void testHandleNeutronPortEvent() throws Exception {
- Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<String, NeutronRouter_Interface>();
+ Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<>();
// Mock variables
Neutron_IPs neutronIP = mock(Neutron_IPs.class);
when(neutronIP.getSubnetUUID()).thenReturn(UUID);
- List<Neutron_IPs> list_neutronIP = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> list_neutronIP = new ArrayList<>();
list_neutronIP.add(neutronIP);
NeutronPort neutronPort = mock(NeutronPort.class);
when(neutronPort.getDeviceOwner()).thenReturn(OWNER_ROUTER_INTERFACE);
Neutron_IPs neutronIP = mock(Neutron_IPs.class);
when(neutronIP.getSubnetUUID()).thenReturn(UUID);
NeutronPort neutronPort = mock(NeutronPort.class);
- List<Neutron_IPs> list_neutronIP = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> list_neutronIP = new ArrayList<>();
list_neutronIP.add(neutronIP);
when(neutronPort.getFixedIPs()).thenReturn(list_neutronIP);
List<NeutronPort> list_neutronPort = new ArrayList<>();
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testProgramFlowsForFloatingIPArpAdd() throws Exception {
- Map<String, Pair> neutronPortToDpIdCache = new HashMap<String, Pair>();
- Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
+ Map<String, Pair> neutronPortToDpIdCache = new HashMap<>();
+ Map<String, String> networkIdToRouterMacCache = new HashMap<>();
Map floatIpDataMapCache = new HashMap();
NeutronFloatingIP neutronFloatingIP = mock(NeutronFloatingIP.class);
ConfigurationService configurationService = mock(ConfigurationService.class);
when(configurationService.getPatchPortName(any(Pair.class))).thenReturn(PORT_INT);
MemberModifier.field(NeutronL3Adapter.class, "configurationService").set(neutronL3Adapter , configurationService);
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(mock(Node.class));
NodeCacheManager nodeCacheManager = mock(NodeCacheManager.class);
when(nodeCacheManager.getBridgeNodes()).thenReturn(nodes);
@Test
public void testHandleInterfaceEvent() throws Exception {
- Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
+ Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<>();
// init instance variables
TenantNetworkManager tenantNetworkManager = mock(TenantNetworkManager.class);
MemberModifier.field(NeutronL3Adapter.class, "tenantNetworkManager").set(neutronL3Adapter , tenantNetworkManager);
@Test
public void testHandleInterfaceEventAdd() throws Exception {
- Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
+ Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<>();
// init instance variables
MemberModifier.field(NeutronL3Adapter.class, "neutronPortToDpIdCache").set(neutronL3Adapter , neutronPortToDpIdCache);
int temp = neutronPortToDpIdCache.size();
@SuppressWarnings("unchecked")
@Test
public void testHandleInterfaceEventDelete() throws Exception {
- Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
+ Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<>();
OvsdbTerminationPointAugmentation intf = mock(OvsdbTerminationPointAugmentation.class);
Uuid uuid = mock(Uuid.class);
when(intf.getInterfaceUuid()).thenReturn(uuid );
@Test
public void testUpdateL3ForNeutronPort() throws Exception {
- Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
+ Map<String, String> networkIdToRouterMacCache = new HashMap<>();
Neutron_IPs neutronIp = mock(Neutron_IPs.class);
when(neutronIp.getIpAddress()).thenReturn(FIXED_IP_ADDRESS);
- List<Neutron_IPs> neutronIps = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> neutronIps = new ArrayList<>();
neutronIps.add(neutronIp);
NeutronPort neutronPort = mock(NeutronPort.class);
when(neutronPort.getNetworkUUID()).thenReturn(UUID);
when(neutronPort.getFixedIPs()).thenReturn(neutronIps);
NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
when(neutronNetwork.getProviderSegmentationID()).thenReturn(ID);
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(mock(Node.class));
PowerMockito.doReturn(Long.valueOf(15)).when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class));
// either add or remove item in l3ForwardingCache
@Test
public void testProgramL3ForwardingStage1() throws Exception {
- Set<String> l3ForwardingCache = new HashSet<String>();
+ Set<String> l3ForwardingCache = new HashSet<>();
NodeId nodeId = mock(NodeId.class);
when(nodeId.getValue()).thenReturn(ID);
@Test
public void testProgramFlowsForNeutronRouterInterface() throws Exception {
- Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
- Map<String, List<Neutron_IPs>> networkIdToRouterIpListCache = new HashMap<String, List<Neutron_IPs>>();
- Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<String, NeutronRouter_Interface>();
+ Map<String, String> networkIdToRouterMacCache = new HashMap<>();
+ Map<String, List<Neutron_IPs>> networkIdToRouterIpListCache = new HashMap<>();
+ Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<>();
NeutronRouter_Interface intf = mock(NeutronRouter_Interface.class);
when(intf.getPortUUID()).thenReturn(UUID);
when(intf.getSubnetUUID()).thenReturn(UUID);
Neutron_IPs neutronIp = mock(Neutron_IPs.class);
when(neutronIp.getIpAddress()).thenReturn(FIXED_IP_ADDRESS);
- List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> ips = new ArrayList<>();
ips.add(neutronIp);
NeutronPort neutronPort = mock(NeutronPort.class);
when(neutronPort.getMacAddress()).thenReturn(MAC_ADDRESS);
NeutronRouter neutronRouter = mock(NeutronRouter.class);
Node node = mock(Node.class);
- List<Node> nodes = new ArrayList<Node>();
+ List<Node> nodes = new ArrayList<>();
nodes.add(node);
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "getDpidForIntegrationBridge", Node.class));
when(neutronNetwork.getProviderSegmentationID()).thenReturn(ID);
Neutron_IPs ip = mock(Neutron_IPs.class);
when(ip.getIpAddress()).thenReturn(IP);
- List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+ List<Neutron_IPs> ips = new ArrayList<>();
ips.add(ip);
ips.add(ip);
ips.add(ip);
@Test
public void testProgramRouterInterfaceStage1() throws Exception {
- Set<String> routerInterfacesCache = new HashSet<String>();
+ Set<String> routerInterfacesCache = new HashSet<>();
NodeId nodeId = mock(NodeId.class);
when(nodeId.getValue()).thenReturn(ID);
//either add or remove staticArpEntryCache
@Test
public void testProgramStaticArpStage1() throws Exception {
- Set<String> staticArpEntryCache = new HashSet<String>();
+ Set<String> staticArpEntryCache = new HashSet<>();
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programStaticArpStage2", Long.class, String.class, String.class, String.class, Action.class));
// either add or remove inboundIpRewriteCache
@Test
public void testProgramInboundIpRewriteStage1() throws Exception {
- Set<String> inboundIpRewriteCache = new HashSet<String>();
+ Set<String> inboundIpRewriteCache = new HashSet<>();
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programInboundIpRewriteStage2", Long.class, Long.class, String.class, String.class, String.class, Action.class));
// either add or remove outboundIpRewriteExclusionCache
@Test
public void testProgramIpRewriteExclusionStage1() throws Exception {
- Set<String> outboundIpRewriteExclusionCache = new HashSet<String>();
+ Set<String> outboundIpRewriteExclusionCache = new HashSet<>();
NodeId nodeId = mock(NodeId.class);
when(nodeId.getValue()).thenReturn(ID);
@SuppressWarnings("unchecked")
@Test
public void testProgramOutboundIpRewriteStage1() throws Exception{
- Set<String> outboundIpRewriteCache = new HashSet<String>();
+ Set<String> outboundIpRewriteCache = new HashSet<>();
MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programOutboundIpRewriteStage2", floatingIpClass, Action.class));
public void setUp(){
NeutronPort neutronPort = mock(NeutronPort.class);
- List<NeutronSecurityGroup> securityGroups = new ArrayList<NeutronSecurityGroup>();
+ List<NeutronSecurityGroup> securityGroups = new ArrayList<>();
securityGroups.add(neutronSecurityGroup);
when(neutronPort.getSecurityGroups()).thenReturn(securityGroups);
NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
when(neutronNetwork.getProviderSegmentationID()).thenReturn(SEG_ID);
when(neutronNetwork.getNetworkUUID()).thenReturn(NETWORK_ID);
- List<NeutronNetwork> listNeutronNetwork = new ArrayList<NeutronNetwork>();
+ List<NeutronNetwork> listNeutronNetwork = new ArrayList<>();
listNeutronNetwork.add(neutronNetwork);
when(neutronNetworkCache.getAllNetworks()).thenReturn(listNeutronNetwork);
when(neutronPort.getNetworkUUID()).thenReturn(NETWORK_ID);
when(neutronPortCache.getPort(anyString())).thenReturn(neutronPort);
- List<OvsdbTerminationPointAugmentation> ports = new ArrayList<OvsdbTerminationPointAugmentation>();
+ List<OvsdbTerminationPointAugmentation> ports = new ArrayList<>();
ports.add(mock(OvsdbTerminationPointAugmentation.class));
when(southbound.getTerminationPointsOfBridge(any(Node.class))).thenReturn(ports);
@Test
public void testGetNetworkId() {
NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
- List<NeutronNetwork> listNeutronNetwork = new ArrayList<NeutronNetwork>();
+ List<NeutronNetwork> listNeutronNetwork = new ArrayList<>();
listNeutronNetwork.add(neutronNetwork);
when(neutronNetwork.getProviderSegmentationID()).thenReturn("segId");
@Before
public void setUp(){
when(southbound.getOvsdbNodeUUID(any(Node.class))).thenReturn(NODE_UUID);
- List<OvsdbTerminationPointAugmentation> ports = new ArrayList<OvsdbTerminationPointAugmentation>();
+ List<OvsdbTerminationPointAugmentation> ports = new ArrayList<>();
OvsdbTerminationPointAugmentation port = mock(OvsdbTerminationPointAugmentation.class);
VlanId vlanId = mock(VlanId.class);
when(vlanId.getValue()).thenReturn(VLAN_ID);
public void createTransactInvokers() {
if (transactInvokers == null) {
try {
- transactInvokers = new HashMap<DatabaseSchema,TransactInvoker>();
+ transactInvokers = new HashMap<>();
List<String> databases = getDatabases().get();
for (String database : databases) {
DatabaseSchema dbSchema = getSchema(database).get();
// OpenVSwitchPart
OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
- Map<String, String> externalIdsMap = new HashMap<String, String>();
+ Map<String, String> externalIdsMap = new HashMap<>();
List<OpenvswitchExternalIds> externalIds = this.initialCreateData.getOpenvswitchExternalIds();
List<OpenvswitchOtherConfigs> otherConfigs = this.initialCreateData.getOpenvswitchOtherConfigs();
if (otherConfigs != null) {
- Map<String, String> otherConfigsMap = new HashMap<String, String>();
+ Map<String, String> otherConfigsMap = new HashMap<>();
for (OpenvswitchOtherConfigs otherConfig : otherConfigs) {
otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
}
public Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> connectionInstancesFromChanges(
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> result =
- new HashMap<InstanceIdentifier<Node>,OvsdbConnectionInstance>();
+ new HashMap<>();
result.putAll(connectionInstancesFromMap(changes.getCreatedData()));
result.putAll(connectionInstancesFromMap(changes.getUpdatedData()));
result.putAll(connectionInstancesFromMap(
DataObject> map) {
Preconditions.checkNotNull(map);
Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> result =
- new HashMap<InstanceIdentifier<Node>,OvsdbConnectionInstance>();
+ new HashMap<>();
for ( Entry<InstanceIdentifier<?>, DataObject> created : map.entrySet()) {
if (created.getValue() instanceof Node) {
OvsdbConnectionInstance client = null;
} catch (SchemaVersionMismatchException e) {
LOG.warn("protocols not supported by this version of ovsdb", e);
}
- List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
+ List<ProtocolEntry> protocolList = new ArrayList<>();
if (protocols != null && protocols.size() > 0) {
ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
SouthboundConstants.OVSDB_PROTOCOL_MAP.inverse();
LOG.debug("createControllerEntries Bridge: {}\n, updatedControllerRows: {}",
bridge, updatedControllerRows);
final Set<UUID> controllerUUIDs = bridge.getControllerColumn().getData();
- final List<ControllerEntry> controllerEntries = new ArrayList<ControllerEntry>();
+ final List<ControllerEntry> controllerEntries = new ArrayList<>();
for (UUID controllerUUID : controllerUUIDs ) {
final Controller controller = updatedControllerRows.get(controllerUUID);
addControllerEntries(controllerEntries, controller);
LOG.debug("createControllerEntries Bridge 2: {}\n, updatedControllerRows: {}",
bridgeNode, updatedControllerRows);
- final List<ControllerEntry> controllerEntriesCreated = new ArrayList<ControllerEntry>();
+ final List<ControllerEntry> controllerEntriesCreated = new ArrayList<>();
final OvsdbBridgeAugmentation ovsdbBridgeAugmentation =
bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
if (ovsdbBridgeAugmentation == null) {
LOG.debug("createManagerEntries OpenVSwitch: {}\n, updatedManagerRows: {}",
ovsdbNode, updatedManagerRows);
final Set<UUID> managerUUIDs = ovsdbNode.getManagerOptionsColumn().getData();
- final List<ManagerEntry> managerEntries = new ArrayList<ManagerEntry>();
+ final List<ManagerEntry> managerEntries = new ArrayList<>();
for (UUID managerUUID : managerUUIDs ) {
final Manager manager = updatedManagerRows.get(managerUUID);
addManagerEntries(managerEntries, manager);
LOG.debug("createManagerEntries based on OVSDB Node: {}\n, updatedManagerRows: {}",
ovsdbNode, updatedManagerRows);
- final List<ManagerEntry> managerEntriesCreated = new ArrayList<ManagerEntry>();
+ final List<ManagerEntry> managerEntriesCreated = new ArrayList<>();
final OvsdbNodeAugmentation ovsdbNodeAugmentation =
ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
if (ovsdbNodeAugmentation == null) {
private void setOpenDaylightExternalIds(Bridge bridge, InstanceIdentifier<OvsdbBridgeAugmentation> iid,
OvsdbBridgeAugmentation ovsdbManagedNode) {
// Set the iid external_id
- Map<String, String> externalIdMap = new HashMap<String, String>();
+ Map<String, String> externalIdMap = new HashMap<>();
externalIdMap.put(SouthboundConstants.IID_EXTERNAL_ID_KEY, SouthboundUtil.serializeInstanceIdentifier(iid));
// Set user provided external ids
List<BridgeExternalIds> bridgeExternalId = ovsdbManagedNode.getBridgeExternalIds();
private void setOpenDaylightOtherConfig(Bridge bridge, OvsdbBridgeAugmentation ovsdbManagedNode) {
List<BridgeOtherConfigs> bridgeOtherConfig = ovsdbManagedNode.getBridgeOtherConfigs();
if (bridgeOtherConfig != null) {
- Map<String, String> otherConfigMap = new HashMap<String, String>();
+ Map<String, String> otherConfigMap = new HashMap<>();
for (BridgeOtherConfigs otherConf : bridgeOtherConfig) {
otherConfigMap.put(otherConf.getBridgeOtherConfigKey(), otherConf.getBridgeOtherConfigValue());
}
private Map<InstanceIdentifier<?>, DataObject> filter(Map<InstanceIdentifier<?>,
DataObject> data) {
Map<InstanceIdentifier<?>, DataObject> result
- = new HashMap<InstanceIdentifier<?>, DataObject>();
+ = new HashMap<>();
for (Entry<InstanceIdentifier<?>, DataObject> entry: data.entrySet()) {
if (isManagedBy(entry.getKey())) {
result.put(entry.getKey(),entry.getValue());
@Override
public Set<InstanceIdentifier<?>> getRemovedPaths() {
if (this.removedPaths == null) {
- this.removedPaths = new HashSet<InstanceIdentifier<?>>();
+ this.removedPaths = new HashSet<>();
for (InstanceIdentifier<?> path: event.getRemovedPaths()) {
if (isManagedBy(path)) {
this.removedPaths.add(path);
// OpenVSwitchPart
OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
- Map<String, String> externalIdsMap = new HashMap<String, String>();
+ Map<String, String> externalIdsMap = new HashMap<>();
List<OpenvswitchExternalIds> externalIds = ovsdbNode.getOpenvswitchExternalIds();
List<OpenvswitchOtherConfigs> otherConfigs = ovsdbNode.getOpenvswitchOtherConfigs();
if (otherConfigs != null) {
- Map<String, String> otherConfigsMap = new HashMap<String, String>();
+ Map<String, String> otherConfigsMap = new HashMap<>();
for (OpenvswitchOtherConfigs otherConfig : otherConfigs) {
otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
}
//Configure optional input
if (terminationPoint.getOptions() != null) {
- Map<String, String> optionsMap = new HashMap<String, String>();
+ Map<String, String> optionsMap = new HashMap<>();
for (Options option : terminationPoint.getOptions()) {
optionsMap.put(option.getOption(), option.getValue());
}
List<InterfaceExternalIds> interfaceExternalIds =
terminationPoint.getInterfaceExternalIds();
if (interfaceExternalIds != null && !interfaceExternalIds.isEmpty()) {
- Map<String, String> externalIdsMap = new HashMap<String, String>();
+ Map<String, String> externalIdsMap = new HashMap<>();
for (InterfaceExternalIds externalId: interfaceExternalIds) {
externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
}
List<InterfaceOtherConfigs> interfaceOtherConfigs =
terminationPoint.getInterfaceOtherConfigs();
if (interfaceOtherConfigs != null && !interfaceOtherConfigs.isEmpty()) {
- Map<String, String> otherConfigsMap = new HashMap<String, String>();
+ Map<String, String> otherConfigsMap = new HashMap<>();
for (InterfaceOtherConfigs interfaceOtherConfig : interfaceOtherConfigs) {
otherConfigsMap.put(interfaceOtherConfig.getOtherConfigKey(),
interfaceOtherConfig.getOtherConfigValue());
List<PortExternalIds> portExternalIds = terminationPoint.getPortExternalIds();
if (portExternalIds != null && !portExternalIds.isEmpty()) {
- Map<String, String> externalIdsMap = new HashMap<String, String>();
+ Map<String, String> externalIdsMap = new HashMap<>();
for (PortExternalIds externalId: portExternalIds) {
externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
}
final Port port) {
if (terminationPoint.getVlanTag() != null) {
- Set<Long> vlanTag = new HashSet<Long>();
+ Set<Long> vlanTag = new HashSet<>();
vlanTag.add(terminationPoint.getVlanTag().getValue().longValue());
port.setTag(vlanTag);
}
final Port port) {
if (terminationPoint.getTrunks() != null && terminationPoint.getTrunks().size() > 0) {
- Set<Long> portTrunks = new HashSet<Long>();
+ Set<Long> portTrunks = new HashSet<>();
List<Trunks> modelTrunks = terminationPoint.getTrunks();
for (Trunks trunk: modelTrunks) {
if (trunk.getTrunk() != null) {
final OvsdbTerminationPointAugmentation terminationPoint,
final Port port) {
if (terminationPoint.getVlanMode() != null) {
- Set<String> portVlanMode = new HashSet<String>();
+ Set<String> portVlanMode = new HashSet<>();
VlanMode modelVlanMode = terminationPoint.getVlanMode();
portVlanMode.add(SouthboundConstants.VLANMODES.values()[modelVlanMode.getIntValue() - 1].getMode());
port.setVlanMode(portVlanMode);
List<PortOtherConfigs> portOtherConfigs =
terminationPoint.getPortOtherConfigs();
if (portOtherConfigs != null && !portOtherConfigs.isEmpty()) {
- Map<String, String> otherConfigsMap = new HashMap<String, String>();
+ Map<String, String> otherConfigsMap = new HashMap<>();
for (PortOtherConfigs portOtherConfig : portOtherConfigs) {
otherConfigsMap.put(portOtherConfig.getOtherConfigKey(),
portOtherConfig.getOtherConfigValue());
//Configure optional input
if (terminationPoint.getOptions() != null) {
- Map<String, String> optionsMap = new HashMap<String, String>();
+ Map<String, String> optionsMap = new HashMap<>();
for (Options option : terminationPoint.getOptions()) {
optionsMap.put(option.getOption(), option.getValue());
}
List<InterfaceExternalIds> interfaceExternalIds =
terminationPoint.getInterfaceExternalIds();
if (interfaceExternalIds != null && !interfaceExternalIds.isEmpty()) {
- Map<String, String> externalIdsMap = new HashMap<String, String>();
+ Map<String, String> externalIdsMap = new HashMap<>();
for (InterfaceExternalIds externalId: interfaceExternalIds) {
externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
}
List<InterfaceOtherConfigs> interfaceOtherConfigs =
terminationPoint.getInterfaceOtherConfigs();
if (interfaceOtherConfigs != null && !interfaceOtherConfigs.isEmpty()) {
- Map<String, String> otherConfigsMap = new HashMap<String, String>();
+ Map<String, String> otherConfigsMap = new HashMap<>();
for (InterfaceOtherConfigs interfaceOtherConfig : interfaceOtherConfigs) {
otherConfigsMap.put(interfaceOtherConfig.getOtherConfigKey(),
interfaceOtherConfig.getOtherConfigValue());
List<PortExternalIds> portExternalIds = terminationPoint.getPortExternalIds();
if (portExternalIds != null && !portExternalIds.isEmpty()) {
- Map<String, String> externalIdsMap = new HashMap<String, String>();
+ Map<String, String> externalIdsMap = new HashMap<>();
for (PortExternalIds externalId: portExternalIds) {
externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
}
final Port port) {
if (terminationPoint.getVlanTag() != null) {
- Set<Long> vlanTag = new HashSet<Long>();
+ Set<Long> vlanTag = new HashSet<>();
vlanTag.add(terminationPoint.getVlanTag().getValue().longValue());
port.setTag(vlanTag);
}
final Port port) {
if (terminationPoint.getTrunks() != null && terminationPoint.getTrunks().size() > 0) {
- Set<Long> portTrunks = new HashSet<Long>();
+ Set<Long> portTrunks = new HashSet<>();
List<Trunks> modelTrunks = terminationPoint.getTrunks();
for (Trunks trunk: modelTrunks) {
if (trunk.getTrunk() != null) {
final OvsdbTerminationPointAugmentation terminationPoint,
final Port port) {
if (terminationPoint.getVlanMode() != null) {
- Set<String> portVlanMode = new HashSet<String>();
+ Set<String> portVlanMode = new HashSet<>();
VlanMode modelVlanMode = terminationPoint.getVlanMode();
portVlanMode.add(SouthboundConstants.VLANMODES.values()[modelVlanMode.getIntValue() - 1].getMode());
port.setVlanMode(portVlanMode);
List<PortOtherConfigs> portOtherConfigs =
terminationPoint.getPortOtherConfigs();
if (portOtherConfigs != null && !portOtherConfigs.isEmpty()) {
- Map<String, String> otherConfigsMap = new HashMap<String, String>();
+ Map<String, String> otherConfigsMap = new HashMap<>();
for (PortOtherConfigs portOtherConfig : portOtherConfigs) {
otherConfigsMap.put(portOtherConfig.getOtherConfigKey(),
portOtherConfig.getOtherConfigValue());
public class TransactCommandAggregator implements TransactCommand {
- private List<TransactCommand> commands = new ArrayList<TransactCommand>();
+ private List<TransactCommand> commands = new ArrayList<>();
private AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes;
private BridgeOperationalState operationalState;
public static Map<InstanceIdentifier<Node>,Node> extractNode(
Map<InstanceIdentifier<?>, DataObject> changes) {
Map<InstanceIdentifier<Node>,Node> result
- = new HashMap<InstanceIdentifier<Node>,Node>();
+ = new HashMap<>();
if (changes != null && changes.entrySet() != null) {
for (Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
if (created.getValue() instanceof Node) {
public static <T extends DataObject> Set<InstanceIdentifier<T>> extractRemoved(
AsyncDataChangeEvent<InstanceIdentifier<?>,DataObject> changes,Class<T> klazz) {
- Set<InstanceIdentifier<T>> result = new HashSet<InstanceIdentifier<T>>();
+ Set<InstanceIdentifier<T>> result = new HashSet<>();
if (changes != null && changes.getRemovedPaths() != null) {
for (InstanceIdentifier<?> iid : changes.getRemovedPaths()) {
if (iid.getTargetType().equals(klazz)) {
public static <T extends DataObject> Map<InstanceIdentifier<T>,T> extract(
Map<InstanceIdentifier<?>, DataObject> changes, Class<T> klazz) {
- Map<InstanceIdentifier<T>,T> result = new HashMap<InstanceIdentifier<T>,T>();
+ Map<InstanceIdentifier<T>,T> result = new HashMap<>();
if (changes != null && changes.entrySet() != null) {
for (Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
if (klazz.isInstance(created.getValue())) {
public static List<Insert> extractInsert(TransactionBuilder transaction, GenericTableSchema schema) {
List<Operation> operations = transaction.getOperations();
- List<Insert> inserts = new ArrayList<Insert>();
+ List<Insert> inserts = new ArrayList<>();
for (int count = 0;count < operations.size();count++) {
Operation operation = operations.get(count);
if (operation instanceof Insert && operation.getTableSchema().equals(schema)) {
Preconditions.checkNotNull(bridgeIid);
Preconditions.checkNotNull(bridge);
List<InstanceIdentifier<ControllerEntry>> result =
- new ArrayList<InstanceIdentifier<ControllerEntry>>();
+ new ArrayList<>();
Bridge oldBridgeNode = oldBridgeRows.get(bridge.getUuid());
if (oldBridgeNode != null && oldBridgeNode.getControllerColumn() != null) {
Preconditions.checkNotNull(openVSwitch);
List<InstanceIdentifier<ManagerEntry>> result =
- new ArrayList<InstanceIdentifier<ManagerEntry>>();
+ new ArrayList<>();
OpenVSwitch oldOvsdbNode = oldOpenVSwitchRows.get(openVSwitch.getUuid());
if (oldOvsdbNode != null && oldOvsdbNode.getManagerOptionsColumn() != null) {
public class OvsdbOperationalCommandAggregator implements TransactionCommand {
- private List<TransactionCommand> commands = new ArrayList<TransactionCommand>();
+ private List<TransactionCommand> commands = new ArrayList<>();
public OvsdbOperationalCommandAggregator(OvsdbConnectionInstance key,TableUpdates updates,
DatabaseSchema dbSchema) {
final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
Set<Long> portTrunks = port.getTrunksColumn().getData();
- List<Trunks> modelTrunks = new ArrayList<Trunks>();
+ List<Trunks> modelTrunks = new ArrayList<>();
if (!portTrunks.isEmpty()) {
for (Long trunk: portTrunks) {
if (trunk != null) {
if (interfaceExternalIds != null && !interfaceExternalIds.isEmpty()) {
Set<String> externalIdKeys = interfaceExternalIds.keySet();
List<InterfaceExternalIds> externalIdsList =
- new ArrayList<InterfaceExternalIds>();
+ new ArrayList<>();
String externalIdValue;
for (String externalIdKey : externalIdKeys) {
externalIdValue = interfaceExternalIds.get(externalIdKey);
Map<String, String> portExternalIds = port.getExternalIdsColumn().getData();
if (portExternalIds != null && !portExternalIds.isEmpty()) {
Set<String> externalIdKeys = portExternalIds.keySet();
- List<PortExternalIds> externalIdsList = new ArrayList<PortExternalIds>();
+ List<PortExternalIds> externalIdsList = new ArrayList<>();
String externalIdValue;
for (String externalIdKey : externalIdKeys) {
externalIdValue = portExternalIds.get(externalIdKey);
Map<String, String> optionsMap = interf.getOptionsColumn().getData();
if (optionsMap != null && !optionsMap.isEmpty()) {
- List<Options> options = new ArrayList<Options>();
+ List<Options> options = new ArrayList<>();
String optionsValueString;
OptionsKey optionsKey;
for (String optionsKeyString : optionsMap.keySet()) {
Map<String, String> portOtherConfigMap = port.getOtherConfigColumn().getData();
if (portOtherConfigMap != null && !portOtherConfigMap.isEmpty()) {
- List<PortOtherConfigs> portOtherConfigs = new ArrayList<PortOtherConfigs>();
+ List<PortOtherConfigs> portOtherConfigs = new ArrayList<>();
String portOtherConfigValueString;
for (String portOtherConfigKeyString : portOtherConfigMap.keySet()) {
portOtherConfigValueString = portOtherConfigMap.get(portOtherConfigKeyString);
Map<String, String> interfaceOtherConfigMap = interf.getOtherConfigColumn().getData();
if (interfaceOtherConfigMap != null && !interfaceOtherConfigMap.isEmpty()) {
- List<InterfaceOtherConfigs> interfaceOtherConfigs = new ArrayList<InterfaceOtherConfigs>();
+ List<InterfaceOtherConfigs> interfaceOtherConfigs = new ArrayList<>();
String interfaceOtherConfigValueString;
for (String interfaceOtherConfigKeyString : interfaceOtherConfigMap.keySet()) {
interfaceOtherConfigValueString = interfaceOtherConfigMap.get(interfaceOtherConfigKeyString);
private static final int QUEUE_SIZE = 10000;
private BindingTransactionChain chain;
private DataBroker db;
- private BlockingQueue<TransactionCommand> inputQueue = new LinkedBlockingQueue<TransactionCommand>(QUEUE_SIZE);
+ private BlockingQueue<TransactionCommand> inputQueue = new LinkedBlockingQueue<>(QUEUE_SIZE);
private BlockingQueue<ReadWriteTransaction> successfulTransactionQueue
- = new LinkedBlockingQueue<ReadWriteTransaction>(QUEUE_SIZE);
+ = new LinkedBlockingQueue<>(QUEUE_SIZE);
private BlockingQueue<AsyncTransaction<?, ?>> failedTransactionQueue
- = new LinkedBlockingQueue<AsyncTransaction<?, ?>>(QUEUE_SIZE);
+ = new LinkedBlockingQueue<>(QUEUE_SIZE);
private ExecutorService executor;
private Map<ReadWriteTransaction,TransactionCommand> transactionToCommand
- = new HashMap<ReadWriteTransaction,TransactionCommand>();
- private List<ReadWriteTransaction> pendingTransactions = new ArrayList<ReadWriteTransaction>();
+ = new HashMap<>();
+ private List<ReadWriteTransaction> pendingTransactions = new ArrayList<>();
private final AtomicBoolean runTask = new AtomicBoolean( true );
public TransactionInvokerImpl(DataBroker db) {
private List<TransactionCommand> extractResubmitCommands() {
AsyncTransaction<?, ?> transaction = failedTransactionQueue.poll();
- List<TransactionCommand> commands = new ArrayList<TransactionCommand>();
+ List<TransactionCommand> commands = new ArrayList<>();
if (transaction != null) {
int index = pendingTransactions.lastIndexOf(transaction);
List<ReadWriteTransaction> transactions =
private void resetTransactionQueue() {
chain.close();
chain = db.createTransactionChain(this);
- pendingTransactions = new ArrayList<ReadWriteTransaction>();
- transactionToCommand = new HashMap<ReadWriteTransaction,TransactionCommand>();
+ pendingTransactions = new ArrayList<>();
+ transactionToCommand = new HashMap<>();
failedTransactionQueue.clear();
successfulTransactionQueue.clear();
}
}
private List<TransactionCommand> extractCommandsFromQueue() throws InterruptedException {
- List<TransactionCommand> result = new ArrayList<TransactionCommand>();
+ List<TransactionCommand> result = new ArrayList<>();
TransactionCommand command = inputQueue.take();
while (command != null) {
result.add(command);
//callback null case
MemberModifier.field(OvsdbConnectionInstance.class, "callback").set(ovsdbConnectionInstance , null);
ListenableFuture<List<String>> listenableFuture = mock(ListenableFuture.class);
- List<String> databases = new ArrayList<String>();
+ List<String> databases = new ArrayList<>();
databases.add("Open_vSwitch");
databases.add("");
doReturn(listenableFuture).when(ovsdbConnectionInstance).getDatabases();
//transactInvokers null case
MemberModifier.field(OvsdbConnectionInstance.class, "transactInvokers").set(ovsdbConnectionInstance , null);
ListenableFuture<List<String>> listenableFuture = mock(ListenableFuture.class);
- List<String> databases = new ArrayList<String>();
+ List<String> databases = new ArrayList<>();
databases.add("database1");
databases.add("database2");
doReturn(listenableFuture).when(ovsdbConnectionInstance).getDatabases();
@SuppressWarnings("unchecked")
@Test
public void testMonitorAllTables() throws Exception {
- Set<String> tables = new HashSet<String>();
+ Set<String> tables = new HashSet<>();
tables.add("tableName1");
tables.add("tableName2");
DatabaseSchema dbSchema = mock(DatabaseSchema.class);
GenericTableSchema tableSchema = mock(GenericTableSchema.class);
when(dbSchema.table(anyString(), eq(GenericTableSchema.class))).thenReturn(tableSchema);
- Set<String> columns = new HashSet<String>();
+ Set<String> columns = new HashSet<>();
columns.add("columnName1");
columns.add("columnName2");
when(tableSchema.getColumns()).thenReturn(columns);
PowerMockito.mockStatic(SouthboundMapper.class);
when(SouthboundMapper.createConnectionInfo(any(OvsdbClient.class))).thenReturn(key);
- clients = new ConcurrentHashMap<ConnectionInfo,OvsdbConnectionInstance>();
+ clients = new ConcurrentHashMap<>();
clients.put(key, ovsdbConnectionInstance);
MemberModifier.field(OvsdbConnectionManager.class, "clients").set(ovsdbConnectionManager, clients);
ConnectionInfo key2 = mock(ConnectionInfo.class);
OvsdbConnectionInstance ovsdbConnectionInstance1 = mock(OvsdbConnectionInstance.class);
OvsdbConnectionInstance ovsdbConnectionInstance2 = mock(OvsdbConnectionInstance.class);
- clients = new ConcurrentHashMap<ConnectionInfo,OvsdbConnectionInstance>();
+ clients = new ConcurrentHashMap<>();
clients.put(key1, ovsdbConnectionInstance1);
clients.put(key2, ovsdbConnectionInstance2);
MemberModifier.field(OvsdbConnectionManager.class, "clients").set(ovsdbConnectionManager, clients);
PowerMockito.mockStatic(SouthboundMapper.class);
when(SouthboundMapper.suppressLocalIpPort(key)).thenReturn(connectionInfo);
- clients = new ConcurrentHashMap<ConnectionInfo,OvsdbConnectionInstance>();
+ clients = new ConcurrentHashMap<>();
MemberModifier.field(OvsdbConnectionManager.class, "clients").set(ovsdbConnectionManager, clients);
//Test putConnectionInstance()
PowerMockito.mockStatic(SouthboundMapper.class);
when(SouthboundMapper.suppressLocalIpPort(key)).thenReturn(connectionInfo);
- instanceIdentifiers = new ConcurrentHashMap<ConnectionInfo,InstanceIdentifier<Node>>();
+ instanceIdentifiers = new ConcurrentHashMap<>();
MemberModifier.field(OvsdbConnectionManager.class, "instanceIdentifiers").set(ovsdbConnectionManager, instanceIdentifiers);
//Test putInstanceIdentifier()
@Test
public void testOnDataChanged() throws Exception {
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes = mock(AsyncDataChangeEvent.class);
- Map<InstanceIdentifier<?>, DataObject> map = new HashMap<InstanceIdentifier<?>, DataObject>();
+ Map<InstanceIdentifier<?>, DataObject> map = new HashMap<>();
InstanceIdentifier<?> iid1 = mock(InstanceIdentifier.class);
OvsdbNodeAugmentation ovsdbNode = mock(OvsdbNodeAugmentation.class);
map.put(iid1, ovsdbNode);
@Test
public void testUpdateData() throws Exception {
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes = mock(AsyncDataChangeEvent.class);
- Map<InstanceIdentifier<Node>, OvsdbConnectionInstance> map = new HashMap<InstanceIdentifier<Node>, OvsdbConnectionInstance>();
+ Map<InstanceIdentifier<Node>, OvsdbConnectionInstance> map = new HashMap<>();
InstanceIdentifier<Node> iid = mock(InstanceIdentifier.class);
OvsdbConnectionInstance connectionInstance = mock(OvsdbConnectionInstance.class);
map.put(iid, connectionInstance);
@Test
public void testDisconnectAndConnectAndInit() throws Exception {
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes = mock(AsyncDataChangeEvent.class);
- Map<InstanceIdentifier<?>, DataObject> originalDataObject = new HashMap<InstanceIdentifier<?>, DataObject>();
- Set<InstanceIdentifier<?>> iiD = new HashSet<InstanceIdentifier<?>>();
+ Map<InstanceIdentifier<?>, DataObject> originalDataObject = new HashMap<>();
+ Set<InstanceIdentifier<?>> iiD = new HashSet<>();
InstanceIdentifier instanceIdentifier = mock(InstanceIdentifier.class);
OvsdbNodeAugmentation ovsdbNode = mock(OvsdbNodeAugmentation.class);
iiD.add(instanceIdentifier);
@Test
public void testUpdateConnections() throws Exception {
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes = mock(AsyncDataChangeEvent.class);
- Map<InstanceIdentifier<?>, DataObject> map = new HashMap<InstanceIdentifier<?>, DataObject>();
+ Map<InstanceIdentifier<?>, DataObject> map = new HashMap<>();
InstanceIdentifier instanceIdentifier = mock(InstanceIdentifier.class);
OvsdbNodeAugmentation value = mock(OvsdbNodeAugmentation.class);
map.put(instanceIdentifier, value);
@Test
public void testConnectionInstancesFromChanges() throws Exception {
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes = mock(AsyncDataChangeEvent.class);
- Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> testResultMap = new HashMap<InstanceIdentifier<Node>,OvsdbConnectionInstance>();
- Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> map1 = new HashMap<InstanceIdentifier<Node>,OvsdbConnectionInstance>();
+ Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> testResultMap = new HashMap<>();
+ Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> map1 = new HashMap<>();
InstanceIdentifier<Node> key1 = mock(InstanceIdentifier.class);
OvsdbConnectionInstance value1 = mock(OvsdbConnectionInstance.class);
map1.put(key1, value1);
@Test
public void testConnectionInstancesFromMap() {
reset(cm);
- Map<InstanceIdentifier<?>,DataObject> map = new HashMap<InstanceIdentifier<?>,DataObject>();
+ Map<InstanceIdentifier<?>,DataObject> map = new HashMap<>();
Node node = mock(Node.class);
InstanceIdentifier<Node> iid = mock(InstanceIdentifier.class);
map.put(iid, node);
OvsdbConnectionInstance client = mock(OvsdbConnectionInstance.class);
- Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> testResultMap = new HashMap<InstanceIdentifier<Node>,OvsdbConnectionInstance>();
+ Map<InstanceIdentifier<Node>,OvsdbConnectionInstance> testResultMap = new HashMap<>();
testResultMap.put(iid, client);
//bridge and client not null case
//bridge null, ovsnode null, and client not null case
when(node.getAugmentation(OvsdbNodeAugmentation.class)).thenReturn(null);
- List<TerminationPoint> terminationPoint = new ArrayList<TerminationPoint>();
+ List<TerminationPoint> terminationPoint = new ArrayList<>();
terminationPoint.add(0, mock(TerminationPoint.class));
when(node.getTerminationPoint()).thenReturn(terminationPoint);
PowerMockito.mockStatic(SouthboundMapper.class);
//when bridge is not empty
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(bridge.getExternalIdsColumn()).thenReturn(column);
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
map.put(SouthboundConstants.IID_EXTERNAL_ID_KEY, "IID_EXTERNAL_ID_KEY");
when(column.getData()).thenReturn(map);
PowerMockito.mockStatic(SouthboundUtil.class);
//when controller is not empty
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(controller.getExternalIdsColumn()).thenReturn(column);
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
map.put(SouthboundConstants.IID_EXTERNAL_ID_KEY, "IID_EXTERNAL_ID_KEY");
when(column.getData()).thenReturn(map);
PowerMockito.mockStatic(SouthboundUtil.class);
Column<GenericTableSchema, Set<String>> column = mock(Column.class);
when(bridge.getDatapathIdColumn()).thenReturn(column);
- Set<String> set = new HashSet<String>();
+ Set<String> set = new HashSet<>();
set.add("dpid");
when(column.getData()).thenReturn(set);
assertNotNull(column.getData());
@Test
public void testCreateOvsdbBridgeProtocols() {
OvsdbBridgeAugmentation ovsdbBridgeNode = mock(OvsdbBridgeAugmentation.class);
- List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
+ List<ProtocolEntry> protocolList = new ArrayList<>();
ProtocolEntry protocolEntry = mock(ProtocolEntry.class);
protocolList.add(protocolEntry);
when(ovsdbBridgeNode.getProtocolEntry()).thenReturn(protocolList);
return (Class<? extends OvsdbBridgeProtocolBase>) OvsdbBridgeProtocolOpenflow10.class;
}
});
- Set<String> protocols = new HashSet<String>();
+ Set<String> protocols = new HashSet<>();
protocols.add("OpenFlow10");
assertEquals(protocols, SouthboundMapper.createOvsdbBridgeProtocols(ovsdbBridgeNode));
}
@Test
public void testCreateMdsalProtocols() throws Exception {
Bridge bridge = mock(Bridge.class);
- Set<String> value = new HashSet<String>();
+ Set<String> value = new HashSet<>();
value.add("OpenFlow10");
Column<GenericTableSchema, Set<String>> column = mock(Column.class);
when(bridge.getProtocolsColumn()).thenReturn(column);
when(column.getData()).thenReturn(value);
- List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
+ List<ProtocolEntry> protocolList = new ArrayList<>();
ProtocolEntry protoEntry = mock(ProtocolEntry.class);
ProtocolEntryBuilder protocolEntryBuilder = mock(ProtocolEntryBuilder.class);
PowerMockito.whenNew(ProtocolEntryBuilder.class).withNoArguments().thenReturn(protocolEntryBuilder);
@Test
public void testCreateControllerEntries() throws Exception {
Bridge bridge = mock(Bridge.class);
- Map<UUID, Controller> updatedControllerRows = new HashMap<UUID, Controller>();
+ Map<UUID, Controller> updatedControllerRows = new HashMap<>();
Column<GenericTableSchema, Set<UUID>> column = mock(Column.class);
when(bridge.getControllerColumn()).thenReturn(column);
- Set<UUID> controllerUUIDs = new HashSet<UUID>();
+ Set<UUID> controllerUUIDs = new HashSet<>();
UUID uuid = mock(UUID.class);
controllerUUIDs.add(uuid);
Controller controller = mock(Controller.class);
updatedControllerRows.put(uuid, controller);
when(column.getData()).thenReturn(controllerUUIDs);
- List<ControllerEntry> controllerEntries = new ArrayList<ControllerEntry>();
+ List<ControllerEntry> controllerEntries = new ArrayList<>();
ControllerEntry controllerEntry = mock(ControllerEntry.class);
controllerEntries.add(controllerEntry);
public void testCreateOvsdbController() throws Exception {
OvsdbBridgeAugmentation omn = mock(OvsdbBridgeAugmentation.class);
DatabaseSchema dbSchema = mock(DatabaseSchema.class);
- List<ControllerEntry> controllerEntries = new ArrayList<ControllerEntry>();
+ List<ControllerEntry> controllerEntries = new ArrayList<>();
ControllerEntry controllerEntry = mock(ControllerEntry.class);
controllerEntries.add(controllerEntry);
when(omn.getControllerEntry()).thenReturn(controllerEntries);
- Map<UUID,Controller> controllerMap = new HashMap<UUID,Controller>();
+ Map<UUID,Controller> controllerMap = new HashMap<>();
PowerMockito.mockStatic(TyperUtils.class);
Controller controller = mock(Controller.class);
PowerMockito.when(TyperUtils.getTypedRowWrapper(any(DatabaseSchema.class), eq(Controller.class))).thenReturn(controller);
@Test
public void testCreateManagerEntries() throws Exception {
OpenVSwitch ovsdbNode = mock(OpenVSwitch.class);
- Map<UUID, Manager> updatedManagerRows = new HashMap<UUID, Manager>();
- Set<UUID> managerUUIDs = new HashSet<UUID>();
+ Map<UUID, Manager> updatedManagerRows = new HashMap<>();
+ Set<UUID> managerUUIDs = new HashSet<>();
UUID managerUUID = mock(UUID.class);
Manager manager = mock(Manager.class);
managerUUIDs.add(managerUUID);
Column<GenericTableSchema, Set<UUID>> column = mock(Column.class);
when(ovsdbNode.getManagerOptionsColumn()).thenReturn(column);
when(column.getData()).thenReturn(managerUUIDs);
- List<ManagerEntry> managerEntries = new ArrayList<ManagerEntry>();
+ List<ManagerEntry> managerEntries = new ArrayList<>();
ManagerEntry managerEntry = mock(ManagerEntry.class);
managerEntries.add(managerEntry);
Column<GenericTableSchema, Map<String, String>> statusColumn = mock(Column.class);
when(manager.getStatusColumn()).thenReturn(statusColumn);
- Map<String, String> statusAttributeMap = new HashMap<String, String>();
+ Map<String, String> statusAttributeMap = new HashMap<>();
when(statusColumn.getData()).thenReturn(statusAttributeMap);
String numberOfConnectionValueStr = "999";
@Test
public void testCreateManagerEntries1() throws Exception {
Node ovsdbNode = mock(Node.class);
- Map<Uri, Manager> updatedManagerRows = new HashMap<Uri, Manager>();
+ Map<Uri, Manager> updatedManagerRows = new HashMap<>();
Uri uri = mock(Uri.class);
Manager manager = mock(Manager.class);
updatedManagerRows.put(uri, manager);
- List<ManagerEntry> managerEntriesCreated = new ArrayList<ManagerEntry>();
+ List<ManagerEntry> managerEntriesCreated = new ArrayList<>();
//ovsdbNodeAugmentation is null
when(ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class)).thenReturn(null);
OvsdbNodeAugmentation ovsdbNodeAugmentation = mock(OvsdbNodeAugmentation.class);
when(ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class)).thenReturn(ovsdbNodeAugmentation);
- List<ManagerEntry> managerEntries = new ArrayList<ManagerEntry>();
+ List<ManagerEntry> managerEntries = new ArrayList<>();
ManagerEntry managerEntry = mock(ManagerEntry.class);
managerEntries.add(managerEntry);
when(ovsdbNodeAugmentation.getManagerEntry()).thenReturn(managerEntries);
Column<GenericTableSchema, Map<String, String>> statusColumn = mock(Column.class);
when(manager.getStatusColumn()).thenReturn(statusColumn);
- Map<String, String> statusAttributeMap = new HashMap<String, String>();
+ Map<String, String> statusAttributeMap = new HashMap<>();
when(statusColumn.getData()).thenReturn(statusAttributeMap);
String numberOfConnectionValueStr = "999";
Node node = mock(Node.class);
Optional<Node> optNode = mock(Optional.class);
TerminationPoint termPnt = mock(TerminationPoint.class);
- List<TerminationPoint> termPntList = new ArrayList<TerminationPoint>();
+ List<TerminationPoint> termPntList = new ArrayList<>();
termPntList.add(termPnt);
TerminationPointKey termPntKey = mock(TerminationPointKey.class);
@RunWith(PowerMockRunner.class)
public class TransactCommandAggregatorTest {
private static final int NUMBER_OF_COMMANDS = 11;
- private List<TransactCommand> commands = new ArrayList<TransactCommand>();
+ private List<TransactCommand> commands = new ArrayList<>();
private TransactCommandAggregator transactCommandAggregator;
@Mock private AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes;
@Mock private BridgeOperationalState operationalState;
PowerMockito.suppress(MemberMatcher.method(TransactUtils.class, "extractUpdated", AsyncDataChangeEvent.class, Class.class));
PowerMockito.when(TransactUtils.extractUpdated(any(AsyncDataChangeEvent.class),eq(DataObject.class))).thenReturn(result);
- Map<InstanceIdentifier<DataObject>, DataObject> map = new HashMap<InstanceIdentifier<DataObject>, DataObject>();
+ Map<InstanceIdentifier<DataObject>, DataObject> map = new HashMap<>();
InstanceIdentifier<DataObject> iid = mock(InstanceIdentifier.class);
DataObject db = mock(DataObject.class);
map.put(iid, db);
PowerMockito.suppress(MemberMatcher.method(TransactUtils.class, "extractCreatedOrUpdated", AsyncDataChangeEvent.class, Class.class));
PowerMockito.when(TransactUtils.extractCreatedOrUpdated(any(AsyncDataChangeEvent.class),eq(DataObject.class))).thenReturn(result);
- Map<InstanceIdentifier<DataObject>, DataObject> map = new HashMap<InstanceIdentifier<DataObject>, DataObject>();
+ Map<InstanceIdentifier<DataObject>, DataObject> map = new HashMap<>();
InstanceIdentifier<DataObject> iid = mock(InstanceIdentifier.class);
DataObject db = mock(DataObject.class);
map.put(iid, db);
TransactionBuilder transaction = mock(TransactionBuilder.class);
GenericTableSchema schema = mock(GenericTableSchema.class);
- List<Operation> operations = new ArrayList<Operation>();
+ List<Operation> operations = new ArrayList<>();
Operation operation = mock(Insert.class);
operations.add(operation);
when(transaction.getOperations()).thenReturn(operations);
@Test
public void testExecute() throws Exception {
PowerMockito.mockStatic(TyperUtils.class);
- Map<UUID, OpenVSwitch> updatedOpenVSwitchRows = new HashMap<UUID, OpenVSwitch>();
+ Map<UUID, OpenVSwitch> updatedOpenVSwitchRows = new HashMap<>();
UUID uuid = mock(UUID.class);
OpenVSwitch ovs = mock(OpenVSwitch.class);
updatedOpenVSwitchRows.put(uuid, ovs);
when(TyperUtils.extractRowsUpdated(eq(OpenVSwitch.class), any(TableUpdates.class), any(DatabaseSchema.class))).thenReturn(updatedOpenVSwitchRows);
- Map<UUID, OpenVSwitch> deletedOpenVSwitchRows = new HashMap<UUID, OpenVSwitch>();
+ Map<UUID, OpenVSwitch> deletedOpenVSwitchRows = new HashMap<>();
OpenVSwitch ovs1 = mock(OpenVSwitch.class);
deletedOpenVSwitchRows.put(uuid, ovs1);
//Test getInstanceIdentifier(): case 1: ovs.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) == true
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
map.put(SouthboundConstants.IID_EXTERNAL_ID_KEY, "iidString");
when(ovs.getExternalIdsColumn()).thenReturn(column);
when(column.getData()).thenReturn(map);
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(openVSwitch.getOtherConfigColumn()).thenReturn(column);
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
when(column.getData()).thenReturn(map);
when(oldEntry.getOtherConfigColumn()).thenReturn(column);
MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "removeOldConfigs", ReadWriteTransaction.class, Map.class, OpenVSwitch.class));
@Test
public void testRemoveOldConfigs() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- Map<String, String> oldOtherConfigs = new HashMap<String, String>();
+ Map<String, String> oldOtherConfigs = new HashMap<>();
oldOtherConfigs.put("OpenvswitchOtherConfigsKey", "OpenvswitchOtherConfigsValue");
OpenVSwitch ovs = mock(OpenVSwitch.class);
doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class));
@Test
public void testSetNewOtherConfigs() throws Exception {
OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = mock(OvsdbNodeAugmentationBuilder.class);
- Map<String, String> otherConfigs = new HashMap<String, String>();
+ Map<String, String> otherConfigs = new HashMap<>();
otherConfigs.put("otherConfigKey", "otherConfigValue");
OpenvswitchOtherConfigsBuilder openvswitchOtherConfigsBuilder = mock(OpenvswitchOtherConfigsBuilder.class);
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(openVSwitch.getExternalIdsColumn()).thenReturn(column);
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
when(column.getData()).thenReturn(map);
when(oldEntry.getExternalIdsColumn()).thenReturn(column);
MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "removeExternalIds", ReadWriteTransaction.class, Map.class, OpenVSwitch.class));
@Test
public void testRemoveExternalIds() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- Map<String, String> oldExternalIds = new HashMap<String, String>();
+ Map<String, String> oldExternalIds = new HashMap<>();
oldExternalIds.put("OpenvswitchExternalIdKey", "OpenvswitchExternalIdValue");
OpenVSwitch ovs = mock(OpenVSwitch.class);
doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class));
@Test
public void testSetNewExternalIds() throws Exception {
OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = mock(OvsdbNodeAugmentationBuilder.class);
- Map<String, String> externalIds = new HashMap<String, String>();
+ Map<String, String> externalIds = new HashMap<>();
externalIds.put("externalIdsKey", "externalIdsValue");
OpenvswitchExternalIdsBuilder openvswitchExternalIdsBuilder = mock(OpenvswitchExternalIdsBuilder.class);
Column<GenericTableSchema, Set<String>> column = mock(Column.class);
when(openVSwitch.getIfaceTypesColumn()).thenReturn(column );
- Set<String> set = new HashSet<String>();
+ Set<String> set = new HashSet<>();
set.add("dpdk");
set.add("dpdkr");
set.add("dpdkvhostuser");
OpenVSwitch openVSwitch = mock(OpenVSwitch.class);
Column<GenericTableSchema, Set<String>> column = mock(Column.class);
when(openVSwitch.getDatapathTypesColumn()).thenReturn(column );
- Set<String> set = new HashSet<String>();
+ Set<String> set = new HashSet<>();
set.add("netdev");
set.add("system");
when(column.getData()).thenReturn(set);
OpenVSwitch openVSwitch = mock(OpenVSwitch.class);
Column<GenericTableSchema, Set<String>> column = mock(Column.class);
when(openVSwitch.getOvsVersionColumn()).thenReturn(column);
- Set<String> set = new HashSet<String>();
+ Set<String> set = new HashSet<>();
set.add("v2.3.0");
when(column.getData()).thenReturn(set);
when(ovsdbNodeBuilder.setOvsVersion(anyString())).thenReturn(ovsdbNodeBuilder);
when(ovsdbBridgeRemovedCommand.getDbSchema()).thenReturn(mock(DatabaseSchema.class));
PowerMockito.mockStatic(TyperUtils.class);
- Map<UUID, Bridge> map = new HashMap<UUID, Bridge>();
+ Map<UUID, Bridge> map = new HashMap<>();
when(TyperUtils.extractRowsRemoved(eq(Bridge.class), any(TableUpdates.class), any(DatabaseSchema.class))).thenReturn(map);
ovsdbBridgeRemovedCommand.execute(transaction);
@PrepareForTest({TyperUtils.class, OvsdbBridgeUpdateCommand.class, SouthboundUtil.class, InstanceIdentifier.class, SouthboundMapper.class, InetAddresses.class, NumberUtils.class, NetworkInterface.class})
@RunWith(PowerMockRunner.class)
public class OvsdbBridgeUpdateCommandTest {
- private Map<UUID,Bridge> updatedBridgeRows = new HashMap<UUID,Bridge>();
- private Map<UUID, Bridge> oldBridgeRows = new HashMap<UUID,Bridge>();
+ private Map<UUID,Bridge> updatedBridgeRows = new HashMap<>();
+ private Map<UUID, Bridge> oldBridgeRows = new HashMap<>();
private OvsdbBridgeUpdateCommand ovsdbBridgeUpdateCommand;
@Before
@Test
public void testDeleteEntries() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- List<InstanceIdentifier<DataObject>> entryIids = new ArrayList<InstanceIdentifier<DataObject>>();
+ List<InstanceIdentifier<DataObject>> entryIids = new ArrayList<>();
InstanceIdentifier<DataObject> iid = mock(InstanceIdentifier.class);
entryIids.add(iid);
doNothing().when(transaction).delete(any(LogicalDatastoreType.class), (InstanceIdentifier<?>) any(List.class));
when(bridge.getUuid()).thenReturn(uuid);
MemberModifier.field(OvsdbBridgeUpdateCommand.class, "oldBridgeRows").set(ovsdbBridgeUpdateCommand, oldBridgeRows);
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
map.put("key", "value");
when(column.getData()).thenReturn(map);
//test protocolEntriesToRemove()
Column<GenericTableSchema, Set<String>> column1 = mock(Column.class);
- Set<String> set = new HashSet<String>();
+ Set<String> set = new HashSet<>();
set.add("element");
when(column1.getData()).thenReturn(set);
when(oldBridge.getProtocolsColumn()).thenReturn(column1);
Bridge bridge = mock(Bridge.class);
Column<GenericTableSchema, Set<String>> column = mock(Column.class);
when(bridge.getFailModeColumn()).thenReturn(column);
- Set<String> set = new HashSet<String>();
+ Set<String> set = new HashSet<>();
set.add("standalone");
when(column.getData()).thenReturn(set);
when(ovsdbBridgeAugmentationBuilder.setFailMode(OvsdbFailModeStandalone.class)).thenReturn(ovsdbBridgeAugmentationBuilder);
Bridge bridge = mock(Bridge.class);
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(bridge.getOtherConfigColumn()).thenReturn(column);
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
map.put("key", "value");
when(column.getData()).thenReturn(map);
Bridge bridge = mock(Bridge.class);
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(bridge.getExternalIdsColumn()).thenReturn(column);
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
map.put("key", "value");
when(column.getData()).thenReturn(map);
PowerMockito.mockStatic(SouthboundMapper.class);
//Test setProtocol()
- List<ProtocolEntry> listProtocolEntry = new ArrayList<ProtocolEntry>();
+ List<ProtocolEntry> listProtocolEntry = new ArrayList<>();
listProtocolEntry.add(mock(ProtocolEntry.class));
when(SouthboundMapper.createMdsalProtocols(any(Bridge.class))).thenReturn(listProtocolEntry);
when(ovsdbBridgeAugmentationBuilder.setProtocolEntry(any(List.class))).thenReturn(ovsdbBridgeAugmentationBuilder);
Bridge bridge = mock(Bridge.class);
PowerMockito.mockStatic(SouthboundMapper.class);
- Map<UUID, Controller> updatedControllerRows = new HashMap<UUID, Controller>();
+ Map<UUID, Controller> updatedControllerRows = new HashMap<>();
when(ovsdbBridgeUpdateCommand.getUpdates()).thenReturn(mock(TableUpdates.class));
when(ovsdbBridgeUpdateCommand.getDbSchema()).thenReturn(mock(DatabaseSchema.class));
PowerMockito.mockStatic(TyperUtils.class);
when(TyperUtils.extractRowsUpdated(eq(Controller.class), any(TableUpdates.class), any(DatabaseSchema.class))).thenReturn(updatedControllerRows);
- List<ControllerEntry> controllerEntryList = new ArrayList<ControllerEntry>();
+ List<ControllerEntry> controllerEntryList = new ArrayList<>();
ControllerEntry controllerEntry = mock(ControllerEntry.class);
controllerEntryList.add(controllerEntry);
when(SouthboundMapper.createControllerEntries(any(Bridge.class), any(Map.class))).thenReturn(controllerEntryList);
@Test
public void testExecute() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- updatedBridgeRows = new HashMap<UUID, Bridge>();
+ updatedBridgeRows = new HashMap<>();
UUID uuid = mock(UUID.class);
Bridge bridge = mock(Bridge.class);
updatedBridgeRows.put(uuid, bridge);
@Test
public void testDeleteControllers() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- List<InstanceIdentifier<ControllerEntry>> controllerEntryIids = new ArrayList<InstanceIdentifier<ControllerEntry>>();
+ List<InstanceIdentifier<ControllerEntry>> controllerEntryIids = new ArrayList<>();
doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
Whitebox.invokeMethod(ovsdbControllerRemovedCommand, "deleteControllers", transaction, controllerEntryIids);
UUID uuid = mock(UUID.class);
Bridge oldBridgeNode = mock(Bridge.class);
- oldBridgeRows = new HashMap<UUID, Bridge>();
+ oldBridgeRows = new HashMap<>();
oldBridgeRows.put(uuid, oldBridgeNode);
when(bridge.getUuid()).thenReturn(uuid);
MemberModifier.field(OvsdbControllerRemovedCommand.class, "oldBridgeRows").set(ovsdbControllerRemovedCommand, oldBridgeRows);
Column<GenericTableSchema, Set<UUID>> column = mock(Column.class);
- Set<UUID> set = new HashSet<UUID>();
+ Set<UUID> set = new HashSet<>();
UUID controllerUuid = mock(UUID.class);
set.add(controllerUuid);
when(column.getData()).thenReturn(set);
@Test
public void testExecute() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- updatedControllerRows = new HashMap<UUID, Controller>();
+ updatedControllerRows = new HashMap<>();
updatedControllerRows.put(mock(UUID.class), mock(Controller.class));
MemberModifier.field(OvsdbControllerUpdateCommand.class, "updatedControllerRows").set(ovsdbControllerUpdateCommand, updatedControllerRows);
MemberModifier.suppress(MemberMatcher.method(OvsdbControllerUpdateCommand.class, "updateController", ReadWriteTransaction.class, Map.class, Map.class));
PowerMockito.verifyPrivate(ovsdbControllerUpdateCommand).invoke("updateController", any(ReadWriteTransaction.class), any(Map.class));
//updatedBridgeRows not null case
- updatedBridgeRows = new HashMap<UUID, Bridge>();
+ updatedBridgeRows = new HashMap<>();
updatedBridgeRows.put(mock(UUID.class), mock(Bridge.class));
MemberModifier.field(OvsdbControllerUpdateCommand.class, "updatedBridgeRows").set(ovsdbControllerUpdateCommand, updatedBridgeRows);
}
updatedBridgeRows.put(mock(UUID.class), bridge);
PowerMockito.mockStatic(SouthboundMapper.class);
- List<ControllerEntry> controllerEntries = new ArrayList<ControllerEntry>();
+ List<ControllerEntry> controllerEntries = new ArrayList<>();
controllerEntries.add(mock(ControllerEntry.class));
when(SouthboundMapper.createControllerEntries(any(Bridge.class), any(Map.class))).thenReturn(controllerEntries);
Column<GenericTableSchema, String> column = mock(Column.class);
@Test
public void testExecute() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- updatedOpenVSwitchRows = new HashMap<UUID, OpenVSwitch>();
+ updatedOpenVSwitchRows = new HashMap<>();
UUID uuid = mock(UUID.class);
OpenVSwitch openVSwitch = mock(OpenVSwitch.class);
updatedOpenVSwitchRows.put(uuid, openVSwitch);
@Test
public void testDeleteManagers() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- List<InstanceIdentifier<ManagerEntry>> managerEntryIids = new ArrayList<InstanceIdentifier<ManagerEntry>>();
+ List<InstanceIdentifier<ManagerEntry>> managerEntryIids = new ArrayList<>();
managerEntryIids.add(mock(InstanceIdentifier.class));
doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
Whitebox.invokeMethod(ovsdbManagersRemovedCommand, "deleteManagers", transaction, managerEntryIids);
UUID uuid = mock(UUID.class);
OpenVSwitch oldOvsdbNode = mock(OpenVSwitch.class);
- oldOpenVSwitchRows = new HashMap<UUID, OpenVSwitch>();
+ oldOpenVSwitchRows = new HashMap<>();
oldOpenVSwitchRows.put(uuid, oldOvsdbNode);
when(openVSwitch.getUuid()).thenReturn(uuid);
MemberModifier.field(OvsdbManagersRemovedCommand.class, "oldOpenVSwitchRows").set(ovsdbManagersRemovedCommand, oldOpenVSwitchRows);
Column<GenericTableSchema, Set<UUID>> column = mock(Column.class);
- Set<UUID> set = new HashSet<UUID>();
+ Set<UUID> set = new HashSet<>();
UUID controllerUuid = mock(UUID.class);
set.add(controllerUuid);
when(column.getData()).thenReturn(set);
public void testCheckIfManagerPresentInUpdatedManagersList() throws Exception {
Manager removedManager = mock(Manager.class);
Manager updatedManager = mock(Manager.class);
- updatedManagerRows = new HashMap<UUID, Manager>();
+ updatedManagerRows = new HashMap<>();
UUID uuid = mock(UUID.class);
updatedManagerRows.put(uuid, updatedManager);
MemberModifier.field(OvsdbManagersRemovedCommand.class, "updatedManagerRows").set(ovsdbManagersRemovedCommand, updatedManagerRows);
@Test
public void testExecute() throws Exception {
ReadWriteTransaction transaction= mock(ReadWriteTransaction.class);
- updatedManagerRows = new HashMap<UUID, Manager>();
+ updatedManagerRows = new HashMap<>();
updatedManagerRows.put(mock(UUID.class), mock(Manager.class));
MemberModifier.field(OvsdbManagersUpdateCommand.class, "updatedManagerRows").set(ovsdbManagersUpdateCommand, updatedManagerRows);
Map<Uri, Manager> updatedManagerRowsWithUri = new HashMap<>();
PowerMockito.doReturn(updatedManagerRowsWithUri).when(ovsdbManagersUpdateCommand, "getUriManagerMap", any(Map.class));
- updatedOpenVSwitchRows = new HashMap<UUID, OpenVSwitch>();
+ updatedOpenVSwitchRows = new HashMap<>();
updatedOpenVSwitchRows.put(mock(UUID.class), mock(OpenVSwitch.class));
MemberModifier.field(OvsdbManagersUpdateCommand.class, "updatedOpenVSwitchRows").set(ovsdbManagersUpdateCommand, updatedOpenVSwitchRows);
updatedOpenVSwitchRows.put(mock(UUID.class), openVSwitch);
PowerMockito.mockStatic(SouthboundMapper.class);
- List<ManagerEntry> managerEntries = new ArrayList<ManagerEntry>();
+ List<ManagerEntry> managerEntries = new ArrayList<>();
managerEntries.add(mock(ManagerEntry.class));
when(SouthboundMapper.createManagerEntries(any(OpenVSwitch.class), any(Map.class))).thenReturn(managerEntries);
@Test
public void testUpdateManagers1() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
- Map<Uri, Manager> updatedManagerRows = new HashMap<Uri, Manager>();
+ Map<Uri, Manager> updatedManagerRows = new HashMap<>();
OvsdbConnectionInstance ovsdbConnectionInstance = mock(OvsdbConnectionInstance.class);
when(ovsdbManagersUpdateCommand.getOvsdbConnectionInstance()).thenReturn(ovsdbConnectionInstance);
InstanceIdentifier<Node> connectionIId = mock(InstanceIdentifier.class);
PowerMockito.doReturn(true).when(ovsdbNodeRemoveCommand, "checkIfOnlyConnectedManager", any(OvsdbNodeAugmentation.class));
- List<ManagedNodeEntry> listManagedNodeEntry = new ArrayList<ManagedNodeEntry>();
+ List<ManagedNodeEntry> listManagedNodeEntry = new ArrayList<>();
ManagedNodeEntry managedNode = mock(ManagedNodeEntry.class);
listManagedNodeEntry.add(managedNode);
when(ovsdbNodeAugmentation.getManagedNodeEntry()).thenReturn(listManagedNodeEntry);
OvsdbNodeAugmentation ovsdbNodeAugmentation = mock(OvsdbNodeAugmentation.class);
ManagerEntry onlyConnectedManager= mock(ManagerEntry.class);
ManagerEntry manager = mock(ManagerEntry.class);
- List<ManagerEntry> listManagerEntry = new ArrayList<ManagerEntry>();
+ List<ManagerEntry> listManagerEntry = new ArrayList<>();
listManagerEntry.add(manager);
//case 1: connectedManager > ONE_CONNECTED_MANAGER
@RunWith(PowerMockRunner.class)
public class OvsdbOperationalCommandAggregatorTest {
private static final int NUMBER_OF_COMMANDS = 9;
- private List<TransactionCommand> commands = new ArrayList<TransactionCommand>();
+ private List<TransactionCommand> commands = new ArrayList<>();
private OvsdbOperationalCommandAggregator ovsdbOperationalCommandAggregator;
@Before
@Test
public void testGetTerminationPointBridge() throws Exception {
UUID portUUID = mock(UUID.class);
- bridgeUpdatedRows = new HashMap<UUID, Bridge>();
+ bridgeUpdatedRows = new HashMap<>();
UUID bridgeUUID = mock(UUID.class);
Bridge bridge = mock(Bridge.class);
bridgeUpdatedRows.put(bridgeUUID, bridge);
private static final int QUEUE_SIZE = 10000;
@Mock private BindingTransactionChain chain;
@Mock private DataBroker db;
- private BlockingQueue<TransactionCommand> inputQueue = new LinkedBlockingQueue<TransactionCommand>(QUEUE_SIZE);
+ private BlockingQueue<TransactionCommand> inputQueue = new LinkedBlockingQueue<>(QUEUE_SIZE);
private BlockingQueue<ReadWriteTransaction> successfulTransactionQueue
- = new LinkedBlockingQueue<ReadWriteTransaction>(QUEUE_SIZE);
+ = new LinkedBlockingQueue<>(QUEUE_SIZE);
private BlockingQueue<AsyncTransaction<?, ?>> failedTransactionQueue
- = new LinkedBlockingQueue<AsyncTransaction<?, ?>>(QUEUE_SIZE);
+ = new LinkedBlockingQueue<>(QUEUE_SIZE);
@Mock private ExecutorService executor;
@Mock private AtomicBoolean runTask;
private Map<ReadWriteTransaction,TransactionCommand> transactionToCommand
- = new HashMap<ReadWriteTransaction,TransactionCommand>();
- private List<ReadWriteTransaction> pendingTransactions = new ArrayList<ReadWriteTransaction>();
+ = new HashMap<>();
+ private List<ReadWriteTransaction> pendingTransactions = new ArrayList<>();
private TransactionInvokerImpl transactionInvokerImpl;
@Before
pendingTransactions.add((ReadWriteTransaction) tx2);
MemberModifier.field(TransactionInvokerImpl.class, "pendingTransactions").set(transactionInvokerImpl, pendingTransactions);
- List<ReadWriteTransaction> transactions= new ArrayList<ReadWriteTransaction>();
+ List<ReadWriteTransaction> transactions= new ArrayList<>();
transactions.add((ReadWriteTransaction) tx1);
TransactionCommand txCommand = mock(TransactionCommand.class);
MemberModifier.field(TransactionInvokerImpl.class, "transactionToCommand").set(transactionInvokerImpl, transactionToCommand);
PowerMockito.suppress(MemberModifier.method(TransactionInvokerImpl.class, "resetTransactionQueue"));
- List<TransactionCommand> testCommands = new ArrayList<TransactionCommand>();
+ List<TransactionCommand> testCommands = new ArrayList<>();
testCommands.add(txCommand);
assertEquals(testCommands, Whitebox.invokeMethod(transactionInvokerImpl, "extractResubmitCommands"));
TransactionCommand command = mock(TransactionCommand.class);
inputQueue.add(command);
MemberModifier.field(TransactionInvokerImpl.class, "inputQueue").set(transactionInvokerImpl, inputQueue);
- List<TransactionCommand> testResult = new ArrayList<TransactionCommand>();
+ List<TransactionCommand> testResult = new ArrayList<>();
testResult.add(command);
assertEquals(testResult, Whitebox.invokeMethod(transactionInvokerImpl, "extractCommandsFromQueue"));
}