Fix incorrect OVSDB class names
[ovsdb.git] / schemas / openvswitch / src / test / java / org / opendaylight / ovsdb / schema / openvswitch / ManagerTestCases.java
1 /*
2  * Copyright (C) 2014 Red Hat, Inc.
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  */
9
10 package org.opendaylight.ovsdb.schema.openvswitch;
11
12 import com.google.common.collect.ImmutableMap;
13 import com.google.common.collect.Sets;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import junit.framework.Assert;
16 import org.junit.Before;
17 import org.junit.Test;
18
19 import org.opendaylight.ovsdb.lib.message.UpdateNotification;
20 import org.opendaylight.ovsdb.lib.notation.Mutator;
21 import org.opendaylight.ovsdb.lib.notation.UUID;
22 import org.opendaylight.ovsdb.lib.operations.OperationResult;
23 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
24
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 import java.io.IOException;
29 import java.util.List;
30 import java.util.concurrent.ExecutionException;
31 import java.util.concurrent.TimeoutException;
32
33 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
34
35
36 public class ManagerTestCases extends OpenVswitchSchemaTestBase {
37     Logger logger = LoggerFactory.getLogger(ManagerTestCases.class);
38
39     @Before
40     public void setUp() throws ExecutionException, InterruptedException, TimeoutException, IOException {
41         super.setUp();
42     }
43
44     @Test
45     public void testCreateTypedManagerTable() throws InterruptedException, ExecutionException, IllegalArgumentException {
46
47         String mgrUuidStr = "sslUuidName";
48         ImmutableMap<String, String> externalIds = ImmutableMap.of("slaveof", "themaster");
49
50         UUID openVSwitchRowUuid = this.getOpenVSwitchTableUuid(ovs, OpenVswitchSchemaSuiteIT.getTableCache());
51         OpenVSwitch openVSwitch = ovs.getTypedRowWrapper(OpenVSwitch.class, null);
52
53         Manager manager = ovs.createTypedRowWrapper(Manager.class);
54         manager.setInactivityProbe(Sets.newHashSet(8192L));
55         manager.setMaxBackoff(Sets.newHashSet(4094L));
56         manager.setTarget(Sets.newHashSet("172.16.50.50:6640"));
57         manager.setExternalIds(externalIds);
58
59         int insertSslOperationIndex = 0;
60         TransactionBuilder transactionBuilder = ovs.transactBuilder(OpenVswitchSchemaSuiteIT.dbSchema)
61                 .add(op.insert(manager.getSchema())
62                         .withId(mgrUuidStr)
63                         .value(manager.getTargetColumn())
64                         .value(manager.getInactivityProbeColumn())
65                         .value(manager.getMaxBackoffColumn())
66                         .value(manager.getExternalIdsColumn()))
67                 .add(op.comment("Inserting Slave Manager"))
68                 .add(op.mutate(openVSwitch.getSchema())
69                         .addMutation(openVSwitch.getManagerOptionsColumn().getSchema(), Mutator.INSERT,
70                                 Sets.newHashSet(new UUID(mgrUuidStr)))
71                         .where(openVSwitch.getUuidColumn().getSchema().opEqual(openVSwitchRowUuid))
72                         .build());
73
74         ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
75         List<OperationResult> operationResults = results.get();
76         Assert.assertFalse(operationResults.isEmpty());
77         for (OperationResult result : operationResults) {
78             Assert.assertNull(result.getError());
79         }
80         // Store the returned SSL row UUID to be used in the TearDown deletion transaction
81         OpenVswitchSchemaSuiteIT.setTestManagerUuid(operationResults.get(insertSslOperationIndex).getUuid());
82         // Check if Results matches the number of operations in transaction
83         Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
84         logger.info("Mutate operation results for Manager = {} ", operationResults);
85
86     }
87
88     @Override
89     public void update(Object context, UpdateNotification upadateNotification) {
90
91     }
92
93     @Override
94     public void locked(Object context, List<String> ids) {
95
96     }
97
98     @Override
99     public void stolen(Object context, List<String> ids) {
100
101     }
102 }