2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.modification;
10 import static org.junit.Assert.assertEquals;
12 import java.util.Optional;
13 import org.apache.commons.lang3.SerializationUtils;
14 import org.junit.Test;
15 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
16 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
17 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 @Deprecated(since = "9.0.0", forRemoval = true)
21 public class DeleteModificationTest extends AbstractModificationTest {
23 public void testApply() throws Exception {
24 // Write something into the datastore
25 DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
26 WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, TEST_CONTAINER);
27 writeModification.apply(writeTransaction);
28 commitTransaction(writeTransaction);
30 // Check if it's in the datastore
31 assertEquals(Optional.of(TEST_CONTAINER), readData(TestModel.TEST_PATH));
33 // Delete stuff from the datastore
34 DOMStoreWriteTransaction deleteTransaction = store.newWriteOnlyTransaction();
35 DeleteModification deleteModification = new DeleteModification(TestModel.TEST_PATH);
36 deleteModification.apply(deleteTransaction);
37 commitTransaction(deleteTransaction);
39 assertEquals(Optional.empty(), readData(TestModel.TEST_PATH));
43 public void testSerialization() {
44 YangInstanceIdentifier path = TestModel.TEST_PATH;
46 DeleteModification expected = new DeleteModification(path);
48 DeleteModification clone = SerializationUtils.clone(expected);
49 assertEquals("getPath", expected.getPath(), clone.getPath());