9b7c971220f66726ef0c1899a7630e4000726496
[moon.git] /
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.aaa.authn.mdsal.store;
10
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;
17
18 public class MDSALConvertTest {
19     @Test
20     public void testConvertDomain() {
21         Domain d = new Domain();
22         d.setDescription("hello");
23         d.setDomainid("hello");
24         d.setEnabled(true);
25         d.setName("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);
31     }
32
33     @Test
34     public void testConvertRole() {
35         Role r = new Role();
36         r.setDescription("hello");
37         r.setRoleid("Hello@hello");
38         r.setName("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);
45     }
46
47     @Test
48     public void testConvertUser() {
49         User u = new User();
50         u.setDescription("hello");
51         u.setDomainid("hello");
52         u.setUserid("hello@hello");
53         u.setName("Hello");
54         u.setEmail("email");
55         u.setEnabled(true);
56         u.setPassword("pass");
57         u.setSalt("salt");
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);
63     }
64
65     @Test
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);
77     }
78 }