1package org.apache.archiva.redback.users.provider.test;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.apache.archiva.redback.users.UserManagerListener;
23import org.apache.archiva.redback.users.User;
2425import java.util.ArrayList;
26import java.util.List;
2728/**29 * UserManagerEventTracker 30 *31 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>32 *33 */34publicclassUserManagerEventTracker35implementsUserManagerListener36 {
37publiclong countInit = 0;
3839public Boolean lastDbFreshness;
4041public List<String> addedUsernames = new ArrayList<String>();
4243public List<String> removedUsernames = new ArrayList<String>();
4445public List<String> updatedUsernames = new ArrayList<String>();
4647publicvoid userManagerInit( boolean freshDatabase )
48 {
49 countInit++;
50 lastDbFreshness = Boolean.valueOf( freshDatabase );
51 }
5253privatevoid addUniqueUsername( List<String> list, User user )
54 {
55if ( !list.contains( user.getUsername() ) )
56 {
57 list.add( user.getUsername() );
58 }
59 }
6061publicvoid userManagerUserAdded( User user )
62 {
63 addUniqueUsername( addedUsernames, user );
64 }
6566publicvoid userManagerUserRemoved( User user )
67 {
68 addUniqueUsername( removedUsernames, user );
69 }
7071publicvoid userManagerUserUpdated( User user )
72 {
73 addUniqueUsername( updatedUsernames, user );
74 }
75 }