Skip to main content
summaryrefslogtreecommitdiffstats
blob: b3d75f8540e1c2da0b6afa880a543ae26a21072c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*******************************************************************************
 * Copyright (c) 2013 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.client.integration.tests.ats.core.client.util;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.client.demo.DemoUsers;
import org.eclipse.osee.ats.client.integration.tests.AtsClientService;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.skynet.core.User;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.junit.Assert;
import org.junit.Before;
import org.mockito.Mockito;

/**
 * @author Donald G. Dunne
 */
public class AtsUserTest {

   private IAtsUser atsUser;
   private User user;

   @Before
   public void setUp() throws OseeCoreException {
      user = UserManager.getUser();
      atsUser = AtsClientService.get().getUserService().getCurrentUser();
   }

   @org.junit.Test
   public void testGetUserId() throws OseeCoreException {
      Assert.assertEquals(user.getUserId(), atsUser.getUserId());
   }

   @org.junit.Test
   public void testGetName() {
      Assert.assertEquals(user.getName(), atsUser.getName());
   }

   @org.junit.Test
   public void testGetEmail() throws OseeCoreException {
      Assert.assertEquals(user.getEmail(), atsUser.getEmail());
   }

   @org.junit.Test
   public void testEquals() throws OseeCoreException {
      Assert.assertEquals(atsUser, user);

      IAtsUser atsUser2 = Mockito.mock(IAtsUser.class);
      Mockito.when(atsUser2.getName()).thenReturn(user.getName());
      Mockito.when(atsUser2.getUserId()).thenReturn(user.getUserId());
      Assert.assertEquals(atsUser, atsUser2);
   }

   @org.junit.Test
   public void testRemove() throws OseeCoreException {
      Collection<IAtsUser> assignees = new HashSet<IAtsUser>();
      assignees.add(AtsClientService.get().getUserServiceClient().getUserFromToken(DemoUsers.Alex_Kay));
      assignees.add(AtsClientService.get().getUserServiceClient().getUserFromToken(DemoUsers.Joe_Smith));
      Assert.assertTrue(Collections.isEqual(
         assignees,
         Arrays.asList(AtsClientService.get().getUserServiceClient().getUserFromToken(DemoUsers.Alex_Kay),
            AtsClientService.get().getUserServiceClient().getUserFromToken(DemoUsers.Joe_Smith))));

      assignees.remove(AtsClientService.get().getUserService().getCurrentUser());
      Assert.assertTrue(Collections.isEqual(assignees,
         Arrays.asList(AtsClientService.get().getUserServiceClient().getUserFromToken(DemoUsers.Alex_Kay))));
   }

}

Back to the top