import java.util.ArrayList;
import java.util.List;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
outerList.add(new OuterListBuilder()
.setId( j )
.setInnerList(buildInnerList(j, innerElements))
- .setKey(new OuterListKey( j ))
+ .withKey(new OuterListKey( j ))
.build());
}
return outerList;
final String itemStr = "Item-" + String.valueOf(index) + "-";
for (int i = 0; i < elements; i++) {
innerList.add(new InnerListBuilder()
- .setKey( new InnerListKey( i ) )
+ .withKey( new InnerListKey( i ) )
.setName(i)
.setValue( itemStr + String.valueOf( i ) )
.build());
for (OuterList element : this.list) {
InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
- .child(OuterList.class, element.getKey());
+ .child(OuterList.class, element.key());
if (oper == StartTestInput.Operation.PUT) {
tx.put(dsType, iid, element);
} else {
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
for (OuterList element : this.list) {
InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
- .child(OuterList.class, element.getKey());
+ .child(OuterList.class, element.key());
if (oper == StartTestInput.Operation.PUT) {
tx.put(dsType, iid, element);
LOG.error("Transaction failed, {}", t);
txError++;
}
- });
+ }, MoreExecutors.directExecutor());
tx = chain.newWriteOnlyTransaction();
writeCnt = 0;
}
} catch (final IllegalStateException e) {
LOG.error("Transaction close failed,", e);
}
- LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
+ LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, txOk + txError);
}
@Override
* @author Thomas Pantelis (originally; re-factored by Michael Vorburger.ch)
*/
public abstract class BindingContext {
+ private static String GET_KEY_METHOD = "key";
public static BindingContext create(final String logName, final Class<? extends DataObject> klass,
final String appConfigListKeyValue) {
final String listKeyValue) throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
// We assume the yang list key type is string.
- Identifier keyInstance = (Identifier) bindingClass.getMethod("getKey").getReturnType()
+ Identifier keyInstance = (Identifier) bindingClass.getMethod(GET_KEY_METHOD).getReturnType()
.getConstructor(String.class).newInstance(listKeyValue);
InstanceIdentifier appConfigPath = InstanceIdentifier.builder((Class)bindingClass, keyInstance).build();
return new ListBindingContext(bindingClass, appConfigPath, listKeyValue);
for (final Node node : nodes) {
if (nodeRegex.matcher(node.getNodeId().getValue()).matches()) {
notifyNode(EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class,
- node.getKey()));
+ node.key()));
}
}
}
package org.opendaylight.controller.messagebus.app.impl;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
EventSourceService getEventSourceService() {
return eventSourceService;
}
-}
+ @VisibleForTesting
+ Map<NodeKey, RoutedRpcRegistration<EventSourceService>> getRoutedRpcRegistrations() {
+ return routedRpcRegistrations;
+ }
+
+ @VisibleForTesting
+ Map<TopicId, EventSourceTopic> getEventSourceTopicMap() {
+ return eventSourceTopicMap;
+ }
+}
doReturn(DataObjectModification.ModificationType.WRITE).when(mockModification).getModificationType();
Node dataObjectNodeMock = mock(Node.class);
- doReturn(getNodeKey("testNodeId01")).when(dataObjectNodeMock).getKey();
+ doReturn(getNodeKey("testNodeId01")).when(dataObjectNodeMock).key();
NodeId nodeIdMock = mock(NodeId.class);
doReturn(nodeIdMock).when(dataObjectNodeMock).getNodeId();
doReturn("nodeIdPattern1").when(nodeIdMock).getValue();
verify(eventSourceServiceMock, times(1)).joinTopic(any(JoinTopicInput.class));
}
- public NodeKey getNodeKey(String nodeId) {
+ public NodeKey getNodeKey(final String nodeId) {
return new NodeKey(new NodeId(nodeId));
}
}
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public void destroyTopicTest() throws Exception {
topicTestHelper();
TopicId topicId = new TopicId("topic-id-007");
- Map<TopicId,EventSourceTopic> localMap = getEventSourceTopicMap();
+ Map<TopicId, EventSourceTopic> localMap = eventSourceTopology.getEventSourceTopicMap();
EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"),
"pattern", eventSourceTopology);
localMap.put(topicId, eventSourceTopic);
public void closeTest() throws Exception {
constructorTestHelper();
topicTestHelper();
- Map<TopicId,EventSourceTopic> localMap = getEventSourceTopicMap();
+ Map<TopicId, EventSourceTopic> localMap = eventSourceTopology.getEventSourceTopicMap();
TopicId topicIdMock = mock(TopicId.class);
EventSourceTopic eventSourceTopic = EventSourceTopic.create(new NotificationPattern("foo"),
"pattern", eventSourceTopology);
EventSource eventSourceMock = mock(EventSource.class);
NodeId nodeId = new NodeId("nodeIdValue1");
nodeKey = new NodeKey(nodeId);
- doReturn(nodeKey).when(nodeMock).getKey();
+ doReturn(nodeKey).when(nodeMock).key();
doReturn(nodeKey).when(eventSourceMock).getSourceNodeKey();
BindingAwareBroker.RoutedRpcRegistration routedRpcRegistrationMock = mock(
BindingAwareBroker.RoutedRpcRegistration.class);
EventSource eventSourceMock = mock(EventSource.class);
NodeId nodeId = new NodeId("nodeIdValue1");
nodeKey = new NodeKey(nodeId);
- Map<NodeKey, BindingAwareBroker.RoutedRpcRegistration<EventSourceService>> localMap =
- getRoutedRpcRegistrations();
+ Map<NodeKey, BindingAwareBroker.RoutedRpcRegistration<EventSourceService>> localMap = eventSourceTopology
+ .getRoutedRpcRegistrations();
NodeKey nodeKeyMock = mock(NodeKey.class);
doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey();
BindingAwareBroker.RoutedRpcRegistration<EventSourceService> routedRpcRegistrationMock =
EventSource eventSourceMock = mock(EventSource.class);
NodeId nodeId = new NodeId("nodeIdValue1");
nodeKey = new NodeKey(nodeId);
- doReturn(nodeKey).when(nodeMock).getKey();
+ doReturn(nodeKey).when(nodeMock).key();
doReturn(nodeKey).when(eventSourceMock).getSourceNodeKey();
BindingAwareBroker.RoutedRpcRegistration routedRpcRegistrationMock = mock(
BindingAwareBroker.RoutedRpcRegistration.class);
assertNotNull("Return value has not been created correctly.",
eventSourceTopology.registerEventSource(eventSourceMock));
}
-
- private Map getEventSourceTopicMap() throws Exception {
- Field nesField = EventSourceTopology.class.getDeclaredField("eventSourceTopicMap");
- nesField.setAccessible(true);
- return (Map) nesField.get(eventSourceTopology);
- }
-
- private Map getRoutedRpcRegistrations() throws Exception {
- Field nesField = EventSourceTopology.class.getDeclaredField("routedRpcRegistrations");
- nesField.setAccessible(true);
- return (Map) nesField.get(eventSourceTopology);
- }
-
}
private TwoLevelListChanged createTestData() {
final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder();
- tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().setKey(new TopLevelListKey("test")).build()));
+ tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build()));
return tb.build();
}
private final List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
private final CountDownLatch latch;
- NotifTestListener(CountDownLatch latch) {
+ NotifTestListener(final CountDownLatch latch) {
this.latch = latch;
}
@Override
- public void onTwoLevelListChanged(TwoLevelListChanged notification) {
+ public void onTwoLevelListChanged(final TwoLevelListChanged notification) {
receivedNotifications.add(notification);
latch.countDown();
}
@Test
public void writeListToList2562Root() {
- final Barroot barRoot = new BarrootBuilder().setType(2).setValue(2).setKey(new BarrootKey(2)).build();
+ final Barroot barRoot = new BarrootBuilder().setType(2).setValue(2).withKey(new BarrootKey(2)).build();
final Fooroot fooRoot = new FoorootBuilder().setBarroot(Arrays.asList(barRoot)).build();
final Root root = new RootBuilder().setFooroot(Arrays.asList(fooRoot)).build();
}
- private TwoLevelListChanged createTestData() {
+ private static TwoLevelListChanged createTestData() {
final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder();
- tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().setKey(new TopLevelListKey("test")).build()));
+ tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build()));
return tb.build();
}
private final List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
private final CountDownLatch latch;
- TestNotifListener(CountDownLatch latch) {
+ TestNotifListener(final CountDownLatch latch) {
this.latch = latch;
}
@Override
- public void onTwoLevelListChanged(TwoLevelListChanged notification) {
+ public void onTwoLevelListChanged(final TwoLevelListChanged notification) {
receivedNotifications.add(notification);
latch.countDown();
}
private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
- private static final TopLevelList NODE = new TopLevelListBuilder().setKey(TOP_LIST_KEY).build();
+ private static final TopLevelList NODE = new TopLevelListBuilder().withKey(TOP_LIST_KEY).build();
@Test
@Deprecated
private final T object;
- public AugmentationVerifier(T objectToVerify) {
+ public AugmentationVerifier(final T objectToVerify) {
this.object = objectToVerify;
}
- public AugmentationVerifier<T> assertHasAugmentation(Class<? extends Augmentation<T>> augmentation) {
+ public AugmentationVerifier<T> assertHasAugmentation(final Class<? extends Augmentation<T>> augmentation) {
assertHasAugmentation(object, augmentation);
return this;
}
- public static <T extends Augmentable<T>> void assertHasAugmentation(T object,
- Class<? extends Augmentation<T>> augmentation) {
+ public static <T extends Augmentable<T>> void assertHasAugmentation(final T object,
+ final Class<? extends Augmentation<T>> augmentation) {
assertNotNull(object);
assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.",
- object.getAugmentation(augmentation));
+ object.augmentation(augmentation));
}
- public static <T extends Augmentable<T>> AugmentationVerifier<T> from(T obj) {
+ public static <T extends Augmentable<T>> AugmentationVerifier<T> from(final T obj) {
return new AugmentationVerifier<>(obj);
}
}
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
- * FIXME: THis test should be moved to sal-binding-broker and rewriten
- * to use new DataBroker API
+ * FIXME: THis test should be moved to sal-binding-broker and rewritten to use new DataBroker API
*/
public class ConcurrentImplicitCreateTest extends AbstractDataServiceTest {
WriteTransaction fooTx = dataBroker.newWriteOnlyTransaction();
WriteTransaction barTx = dataBroker.newWriteOnlyTransaction();
- fooTx.put(LogicalDatastoreType.OPERATIONAL, FOO_PATH, new TopLevelListBuilder().setKey(FOO_KEY).build());
- barTx.put(LogicalDatastoreType.OPERATIONAL, BAR_PATH, new TopLevelListBuilder().setKey(BAR_KEY).build());
+ fooTx.put(LogicalDatastoreType.OPERATIONAL, FOO_PATH, new TopLevelListBuilder().withKey(FOO_KEY).build());
+ barTx.put(LogicalDatastoreType.OPERATIONAL, BAR_PATH, new TopLevelListBuilder().withKey(BAR_KEY).build());
fooTx.submit().get(5, TimeUnit.SECONDS);
barTx.submit().get(5, TimeUnit.SECONDS);
protected static final InstanceIdentifier<ListViaUses> DEEP_WILDCARDED_PATH = InstanceIdentifier
.builder(Top.class)
- .child(TopLevelList.class) //
- .augmentation(TreeComplexUsesAugment.class) //
- .child(ListViaUses.class) //
+ .child(TopLevelList.class)
+ .augmentation(TreeComplexUsesAugment.class)
+ .child(ListViaUses.class)
.build();
private static final InstanceIdentifier<TreeComplexUsesAugment> NODE_0_TCU_PATH = InstanceIdentifier
.builder(Top.class)
- .child(TopLevelList.class, TOP_LEVEL_LIST_0_KEY) //
- .augmentation(TreeComplexUsesAugment.class) //
+ .child(TopLevelList.class, TOP_LEVEL_LIST_0_KEY)
+ .augmentation(TreeComplexUsesAugment.class)
.build();
private static final InstanceIdentifier<TreeComplexUsesAugment> NODE_1_TCU_PATH = InstanceIdentifier
.builder(Top.class)
- .child(TopLevelList.class, TOP_LEVEL_LIST_1_KEY) //
- .augmentation(TreeComplexUsesAugment.class) //
+ .child(TopLevelList.class, TOP_LEVEL_LIST_1_KEY)
+ .augmentation(TreeComplexUsesAugment.class)
.build();
private static final ListViaUsesKey LIST_VIA_USES_KEY = new ListViaUsesKey("test");
- private static final InstanceIdentifier<ListViaUses> NODE_0_LVU_PATH = NODE_0_TCU_PATH.child(ListViaUses.class, LIST_VIA_USES_KEY);
+ private static final InstanceIdentifier<ListViaUses> NODE_0_LVU_PATH = NODE_0_TCU_PATH.child(ListViaUses.class,
+ LIST_VIA_USES_KEY);
- private static final InstanceIdentifier<ListViaUses> NODE_1_LVU_PATH = NODE_1_TCU_PATH.child(ListViaUses.class, LIST_VIA_USES_KEY);
+ private static final InstanceIdentifier<ListViaUses> NODE_1_LVU_PATH = NODE_1_TCU_PATH.child(ListViaUses.class,
+ LIST_VIA_USES_KEY);
private static final InstanceIdentifier<ContainerWithUses> NODE_0_CWU_PATH =
NODE_0_TCU_PATH.child(ContainerWithUses.class);
- private static final ContainerWithUses CWU= new ContainerWithUsesBuilder()//
- .setLeafFromGrouping("some container value") //
- .build();
+ private static final ContainerWithUses CWU = new ContainerWithUsesBuilder()
+ .setLeafFromGrouping("some container value").build();
- private static final ListViaUses LVU = new ListViaUsesBuilder() //
- .setKey(LIST_VIA_USES_KEY) //
- .setName("john")
- .build();
+ private static final ListViaUses LVU = new ListViaUsesBuilder()
+ .withKey(LIST_VIA_USES_KEY).setName("john").build();
@Override
protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
private static final List11Key LIST11_KEY = new List11Key(100);
- private static final InstanceIdentifier<TllComplexAugment> TLL_COMPLEX_AUGMENT_PATH = InstanceIdentifier.builder(Top.class)
+ private static final InstanceIdentifier<TllComplexAugment> TLL_COMPLEX_AUGMENT_PATH = InstanceIdentifier
+ .builder(Top.class)
.child(TopLevelList.class,FOO_KEY)
.augmentation(TllComplexAugment.class)
.build();
initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, list11Before, true);
initTx.submit().get(5, TimeUnit.SECONDS);
- List11 list11After = new List11Builder().setKey(LIST11_KEY).setAttrStr("good").build();
+ List11 list11After = new List11Builder().withKey(LIST11_KEY).setAttrStr("good").build();
final TestListener<List11> listener = createListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH,
added(LIST11_PATH, list11Before), subtreeModified(LIST11_PATH, list11Before, list11After));
listener.verify();
}
- private List11 createList11() {
+ private static List11 createList11() {
List11Builder builder = new List11Builder()
- .setKey(LIST11_KEY)
+ .withKey(LIST11_KEY)
.addAugmentation(List11SimpleAugment.class,new List11SimpleAugmentBuilder()
.setAttrStr2("bad").build())
.setAttrStr("good");
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.sal.binding.test.bugfix;
import static org.junit.Assert.assertEquals;
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
- TopLevelList tll = new TopLevelListBuilder().setKey(TLL_KEY)
+ TopLevelList tll = new TopLevelListBuilder().withKey(TLL_KEY)
.addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment).build();
transaction.put(OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true);
transaction.submit().get(5, TimeUnit.SECONDS);
private static final List11Key LIST11_KEY = new List11Key(LIST11_ID);
private static final List1Key LIST1_KEY = new List1Key(LIST1_NAME);
- private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) //
+ private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class)
.child(TopLevelList.class, TLL_KEY).build();
- private static final InstanceIdentifier<List1> LIST1_INSTANCE_ID_BA = //
- TLL_INSTANCE_ID_BA.builder() //
+ private static final InstanceIdentifier<List1> LIST1_INSTANCE_ID_BA =
+ TLL_INSTANCE_ID_BA.builder()
.augmentation(TllComplexAugment.class).child(List1.class, LIST1_KEY).build();
- private static final InstanceIdentifier<? extends DataObject> LIST11_INSTANCE_ID_BA = //
+ private static final InstanceIdentifier<? extends DataObject> LIST11_INSTANCE_ID_BA =
LIST1_INSTANCE_ID_BA.child(List11.class, LIST11_KEY);
/**
DataBroker dataBroker = testContext.getDataBroker();
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
- List11 list11 = new List11Builder() //
- .setKey(LIST11_KEY) //
- .setAttrStr("primary")
- .build();
-
- List1 list1 = new List1Builder().setKey(LIST1_KEY).setList11(ImmutableList.of(list11)).build();
+ List11 list11 = new List11Builder().withKey(LIST11_KEY).setAttrStr("primary").build();
+ List1 list1 = new List1Builder().withKey(LIST1_KEY).setList11(ImmutableList.of(list11)).build();
transaction.put(LogicalDatastoreType.OPERATIONAL, LIST1_INSTANCE_ID_BA, list1, true);
transaction.submit().get(5, TimeUnit.SECONDS);
DataBroker dataBroker = testContext.getDataBroker();
Optional<TopLevelList> tllFoo = dataBroker.newReadOnlyTransaction().read(
- LogicalDatastoreType.CONFIGURATION, FOO_PATH).checkedGet(5, TimeUnit.SECONDS);
+ LogicalDatastoreType.CONFIGURATION, FOO_PATH).get(5, TimeUnit.SECONDS);
assertFalse(tllFoo.isPresent());
TopLevelList tllFooData = createTll(TLL_FOO_KEY);
transaction.submit().get(5, TimeUnit.SECONDS);
Optional<TopLevelList> readedData = dataBroker.newReadOnlyTransaction().read(
- LogicalDatastoreType.CONFIGURATION, FOO_PATH).checkedGet(5, TimeUnit.SECONDS);
+ LogicalDatastoreType.CONFIGURATION, FOO_PATH).get(5, TimeUnit.SECONDS);
assertTrue(readedData.isPresent());
- assertEquals(tllFooData.getKey(), readedData.get().getKey());
+ assertEquals(tllFooData.key(), readedData.get().key());
TopLevelList nodeBarData = createTll(TLL_BAR_KEY);
TopLevelList nodeBazData = createTll(TLL_BAZ_KEY);
insertMoreTr.submit().get(5, TimeUnit.SECONDS);
Optional<Top> top = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, TOP_PATH)
- .checkedGet(5, TimeUnit.SECONDS);
+ .get(5, TimeUnit.SECONDS);
assertTrue(top.isPresent());
assertEquals(3, top.get().getTopLevelList().size());
removalTransaction.submit().get(5, TimeUnit.SECONDS);
Optional<TopLevelList> readedData2 = dataBroker.newReadOnlyTransaction().read(
- LogicalDatastoreType.CONFIGURATION, BAR_PATH).checkedGet(5, TimeUnit.SECONDS);
+ LogicalDatastoreType.CONFIGURATION, BAR_PATH).get(5, TimeUnit.SECONDS);
assertFalse(readedData2.isPresent());
}
private static TopLevelList createTll(final TopLevelListKey key) {
- TopLevelListBuilder ret = new TopLevelListBuilder();
- ret.setKey(key);
- return ret.build();
+ return new TopLevelListBuilder().withKey(key).build();
}
}
InstanceIdentifier<UnorderedList> node1 = createNodeRef("0");
Optional<UnorderedList> node = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1)
- .checkedGet(5, TimeUnit.SECONDS);
+ .get(5, TimeUnit.SECONDS);
assertFalse(node.isPresent());
UnorderedList nodeData1 = createNode("0");
transaction.put(LogicalDatastoreType.OPERATIONAL, node1, nodeData1);
- transaction.submit().checkedGet(5, TimeUnit.SECONDS);
+ transaction.submit().get(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
- node1).checkedGet(5, TimeUnit.SECONDS);
+ node1).get(5, TimeUnit.SECONDS);
assertTrue(readedData.isPresent());
- assertEquals(nodeData1.getKey(), readedData.get().getKey());
+ assertEquals(nodeData1.key(), readedData.get().key());
final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
assertNotNull(transaction2);
transaction2.delete(LogicalDatastoreType.OPERATIONAL, node1);
- transaction2.submit().checkedGet(5, TimeUnit.SECONDS);
+ transaction2.submit().get(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData2 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
- node1).checkedGet(5, TimeUnit.SECONDS);
+ node1).get(5, TimeUnit.SECONDS);
assertFalse(readedData2.isPresent());
}
private static InstanceIdentifier<UnorderedList> createNodeRef(final String string) {
UnorderedListKey key = new UnorderedListKey(string);
- return InstanceIdentifier.builder(Lists.class).child(UnorderedContainer.class).child(UnorderedList.class, key).build();
+ return InstanceIdentifier.builder(Lists.class).child(UnorderedContainer.class).child(UnorderedList.class, key)
+ .build();
}
private static UnorderedList createNode(final String string) {
UnorderedListBuilder ret = new UnorderedListBuilder();
UnorderedListKey nodeKey = new UnorderedListKey(string);
- ret.setKey(nodeKey);
+ ret.withKey(nodeKey);
ret.setName("name of " + string);
ret.setName("value of " + string);
return ret.build();
}
public static TopLevelList topLevelList(final TopLevelListKey key) {
- return new TopLevelListBuilder().setKey(key).build();
+ return new TopLevelListBuilder().withKey(key).build();
}
public static TopLevelList topLevelList(final TopLevelListKey key, final TreeComplexUsesAugment augment) {
- TopLevelListBuilder builder = new TopLevelListBuilder().setKey(key);
+ TopLevelListBuilder builder = new TopLevelListBuilder().withKey(key);
builder.addAugmentation(TreeComplexUsesAugment.class, augment);
return builder.build();
}
public static TreeComplexUsesAugment complexUsesAugment(final ListViaUsesKey... keys) {
ImmutableList.Builder<ListViaUses> listViaUses = ImmutableList.<ListViaUses>builder();
for (ListViaUsesKey key : keys) {
- listViaUses.add(new ListViaUsesBuilder().setKey(key).build());
+ listViaUses.add(new ListViaUsesBuilder().withKey(key).build());
}
return new TreeComplexUsesAugmentBuilder().setListViaUses(listViaUses.build()).build();
}
- public static TreeLeafOnlyUsesAugment leafOnlyUsesAugment(String leafFromGroupingValue) {
+ public static TreeLeafOnlyUsesAugment leafOnlyUsesAugment(final String leafFromGroupingValue) {
return new TreeLeafOnlyUsesAugmentBuilder().setLeafFromGrouping(leafFromGroupingValue).build();
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.clustering.it.listener;
import com.google.common.util.concurrent.FutureCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class PeopleCarListener implements CarPurchaseListener {
private static final Logger LOG = LoggerFactory.getLogger(PeopleCarListener.class);
private DataBroker dataProvider;
-
-
public void setDataProvider(final DataBroker salDataProvider) {
this.dataProvider = salDataProvider;
}
@Override
- public void onCarBought(CarBought notification) {
+ public void onCarBought(final CarBought notification) {
final CarPersonBuilder carPersonBuilder = new CarPersonBuilder();
carPersonBuilder.setCarId(notification.getCarId());
carPersonBuilder.setPersonId(notification.getPersonId());
CarPersonKey key = new CarPersonKey(notification.getCarId(), notification.getPersonId());
- carPersonBuilder.setKey(key);
+ carPersonBuilder.withKey(key);
final CarPerson carPerson = carPersonBuilder.build();
LOG.info("Car bought, adding car-person entry: [{}]", carPerson);
- InstanceIdentifier<CarPerson> carPersonIId = InstanceIdentifier.<CarPeople>builder(CarPeople.class)
- .child(CarPerson.class, carPerson.getKey()).build();
+ InstanceIdentifier<CarPerson> carPersonIId = InstanceIdentifier.builder(CarPeople.class)
+ .child(CarPerson.class, carPerson.key()).build();
WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
import com.google.common.base.Stopwatch;
import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
failureCounter.set(0);
WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
- InstanceIdentifier<Cars> carsId = InstanceIdentifier.<Cars>builder(Cars.class).build();
+ InstanceIdentifier<Cars> carsId = InstanceIdentifier.create(Cars.class);
tx.merge(LogicalDatastoreType.CONFIGURATION, carsId, new CarsBuilder().build());
try {
tx.submit().checkedGet(5, TimeUnit.SECONDS);
WriteTransaction tx1 = dataProvider.newWriteOnlyTransaction();
CarEntry car = new CarEntryBuilder().setId(new CarId("car" + id)).build();
tx1.put(LogicalDatastoreType.CONFIGURATION,
- InstanceIdentifier.<Cars>builder(Cars.class).child(CarEntry.class, car.getKey()).build(),
- car);
- CheckedFuture<Void, TransactionCommitFailedException> future = tx1.submit();
- Futures.addCallback(future, new FutureCallback<Void>() {
+ InstanceIdentifier.<Cars>builder(Cars.class).child(CarEntry.class, car.key()).build(), car);
+ Futures.addCallback(tx1.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.clustering.it.provider;
import com.google.common.util.concurrent.FutureCallback;
final SettableFuture<RpcResult<AddPersonOutput>> futureResult = SettableFuture.create();
// Each entry will be identifiable by a unique key, we have to create that identifier
- final InstanceIdentifier.InstanceIdentifierBuilder<Person> personIdBuilder =
- InstanceIdentifier.<People>builder(People.class)
- .child(Person.class, person.getKey());
- final InstanceIdentifier<Person> personId = personIdBuilder.build();
+ final InstanceIdentifier<Person> personId = InstanceIdentifier.builder(People.class)
+ .child(Person.class, person.key()).build();
// Place entry in data store tree
WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.CONFIGURATION, personId, person, true);