2 * Copyright (c) 2014 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.md.sal.dom.store.impl;
10 import org.junit.Test;
13 * Base template for a test suite for testing DataChangeListener functionality.
15 public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataChangeListenerTest {
17 protected static final String FOO_SIBLING = "foo-sibling";
20 * Callback invoked when the test suite can modify task parameters.
22 * @param task Update task configuration as needed
24 protected abstract void customizeTask(DatastoreTestTask task);
27 public final void putTopLevelOneNested() throws Exception {
29 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR));
32 putTopLevelOneNested(task);
35 protected abstract void putTopLevelOneNested(DatastoreTestTask task) throws Exception;
38 public final void existingTopWriteSibling() throws Exception {
39 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
40 tx -> tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build()));
43 existingTopWriteSibling(task);
46 protected abstract void existingTopWriteSibling(DatastoreTestTask task) throws Exception;
49 public final void existingTopWriteTwoNested() throws Exception {
50 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
52 tx.write(path(FOO,BAR), nestedList(BAR).build());
53 tx.write(path(FOO,BAZ), nestedList(BAZ).build());
57 existingTopWriteTwoNested(task);
60 protected abstract void existingTopWriteTwoNested(DatastoreTestTask task) throws Exception;
64 public final void existingOneNestedWriteAdditionalNested() throws Exception {
65 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
66 tx -> tx.write(path(FOO,BAZ), nestedList(BAZ).build()));
69 existingOneNestedWriteAdditionalNested(task);
72 protected abstract void existingOneNestedWriteAdditionalNested(DatastoreTestTask task) throws Exception;
75 public final void replaceTopLevelNestedChanged() throws Exception {
76 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
77 writeOneTopMultipleNested(FOO, BAZ));
80 replaceTopLevelNestedChanged(task);
83 protected abstract void replaceTopLevelNestedChanged(DatastoreTestTask task) throws Exception;
86 public final void putTopLevelWithTwoNested() throws Exception {
88 DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR, BAZ));
91 putTopLevelWithTwoNested(task);
94 protected abstract void putTopLevelWithTwoNested(DatastoreTestTask task) throws Exception;
97 public final void twoNestedExistsOneIsDeleted() throws Exception {
99 DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR, BAZ)).test(
100 deleteNested(FOO, BAZ));
103 twoNestedExistsOneIsDeleted(task);
106 protected abstract void twoNestedExistsOneIsDeleted(DatastoreTestTask task) throws Exception;
109 public final void nestedListExistsRootDeleted() throws Exception {
111 DatastoreTestTask task = newTestTask().cleanup(null).setup(writeOneTopMultipleNested(FOO, BAR, BAZ))
112 .test(DatastoreTestTask.simpleDelete(TOP_LEVEL));
115 nestedListExistsRootDeleted(task);
118 protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws Exception;