2 * Copyright (c) 2016 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
9 package org.opendaylight.aaa.authn.mdsal.store;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.aaa.api.model.Domain;
14 import org.opendaylight.aaa.api.model.Grant;
15 import org.opendaylight.aaa.api.model.Role;
16 import org.opendaylight.aaa.api.model.User;
18 public class MDSALConvertTest {
20 public void testConvertDomain() {
21 Domain d = new Domain();
22 d.setDescription("hello");
23 d.setDomainid("hello");
26 org.opendaylight.yang.gen.v1.urn.aaa.yang.authn.claims.rev141029.authentication.Domain mdsalDomain = IDMObject2MDSAL.toMDSALDomain(d);
27 Assert.assertNotNull(mdsalDomain);
28 Domain d2 = IDMObject2MDSAL.toIDMDomain(mdsalDomain);
29 Assert.assertNotNull(d2);
30 Assert.assertEquals(d, d2);
34 public void testConvertRole() {
36 r.setDescription("hello");
37 r.setRoleid("Hello@hello");
39 r.setDomainid("hello");
40 org.opendaylight.yang.gen.v1.urn.aaa.yang.authn.claims.rev141029.authentication.Role mdsalRole = IDMObject2MDSAL.toMDSALRole(r);
41 Assert.assertNotNull(mdsalRole);
42 Role r2 = IDMObject2MDSAL.toIDMRole(mdsalRole);
43 Assert.assertNotNull(r2);
44 Assert.assertEquals(r, r2);
48 public void testConvertUser() {
50 u.setDescription("hello");
51 u.setDomainid("hello");
52 u.setUserid("hello@hello");
56 u.setPassword("pass");
58 org.opendaylight.yang.gen.v1.urn.aaa.yang.authn.claims.rev141029.authentication.User mdsalUser = IDMObject2MDSAL.toMDSALUser(u);
59 Assert.assertNotNull(mdsalUser);
60 User u2 = IDMObject2MDSAL.toIDMUser(mdsalUser);
61 Assert.assertNotNull(u2);
62 Assert.assertEquals(u, u2);
66 public void testConvertGrant() {
67 Grant g = new Grant();
68 g.setDomainid("hello");
69 g.setUserid("hello@hello");
70 g.setRoleid("hello@hello");
71 g.setGrantid("hello@hello@Hello");
72 org.opendaylight.yang.gen.v1.urn.aaa.yang.authn.claims.rev141029.authentication.Grant mdsalGrant = IDMObject2MDSAL.toMDSALGrant(g);
73 Assert.assertNotNull(mdsalGrant);
74 Grant g2 = IDMObject2MDSAL.toIDMGrant(mdsalGrant);
75 Assert.assertNotNull(g2);
76 Assert.assertEquals(g, g2);