Deleting a non-existent node fails
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / impl / test / Bug4494Test.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.md.sal.binding.impl.test;
9
10 import java.util.ArrayList;
11 import org.junit.Test;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
14 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
15 import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
16 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23
24 public class Bug4494Test extends AbstractDataBrokerTest {
25     @Test
26     public void testDelete() throws Exception {
27         DataBroker dataBroker = getDataBroker();
28         WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
29         ArrayList<TopLevelList> list = new ArrayList<>();
30         list.add(new TopLevelListBuilder().setName("name").build());
31         TopBuilder builder = new TopBuilder().setTopLevelList(list);
32         writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Top.class), builder.build());
33         assertCommit(writeTransaction.submit());
34
35         InstanceIdentifier<TopLevelList> id = InstanceIdentifier.builder(Top.class)
36             .child(TopLevelList.class, new TopLevelListKey("name")).build();
37
38         ReadWriteTransaction writeTransaction1 = dataBroker.newReadWriteTransaction();
39
40         writeTransaction1.delete(LogicalDatastoreType.OPERATIONAL, id);
41         assertCommit(writeTransaction1.submit());
42         ReadWriteTransaction writeTransaction2 = dataBroker.newReadWriteTransaction();
43
44         writeTransaction2.delete(LogicalDatastoreType.OPERATIONAL, id);
45         assertCommit(writeTransaction2.submit());
46     }
47 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.