blob: 7b12ac7eb285350e199cd77625013aecde2244c3 [file] [log] [blame]
Yuli Shlosberga4eeb112019-01-07 16:23:36 +02001package org.onap.sdc.security;
2
3import org.junit.Test;
4
5import java.io.IOException;
6import java.util.HashSet;
7import java.util.Set;
8
9import static org.junit.Assert.assertTrue;
10
11public class RepresentationUtilsTest {
12
13 private static AuthenticationCookie originalCookie = new AuthenticationCookie("kuku");
14
15 @Test
16 public void representationE2EwithRoleNull() throws IOException {
17 originalCookie.setRoles(null);
18 String jsonStr = RepresentationUtils.toRepresentation(originalCookie);
19 AuthenticationCookie cookieFromJson = RepresentationUtils.fromRepresentation(jsonStr, AuthenticationCookie.class);
20 assertTrue(originalCookie.equals(cookieFromJson));
21 }
22
23 @Test
24 public void representationE2EwithRoleNotNull() throws IOException {
25 Set<String> roles = new HashSet<String>();
26 roles.add("Designer");
27 roles.add("Admin");
28 roles.add("Tester");
29 originalCookie.setRoles(roles);
30 String jsonStr = RepresentationUtils.toRepresentation(originalCookie);
31 AuthenticationCookie cookieFromJson = RepresentationUtils.fromRepresentation(jsonStr, AuthenticationCookie.class);
32 assertTrue(originalCookie.equals(cookieFromJson));
33 }
34}