blob: 80dcbe1fc085816d4908b8b54502b0c6ca2fa756 [file] [log] [blame]
package org.apache.archiva.redback.users.provider.test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.redback.users.UserManagerListener;
import org.apache.archiva.redback.users.User;
import java.util.ArrayList;
import java.util.List;
/**
* UserManagerEventTracker
*
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*
*/
public class UserManagerEventTracker
implements UserManagerListener
{
public long countInit = 0;
public Boolean lastDbFreshness;
public List<String> addedUsernames = new ArrayList<String>();
public List<String> removedUsernames = new ArrayList<String>();
public List<String> updatedUsernames = new ArrayList<String>();
public void userManagerInit( boolean freshDatabase )
{
countInit++;
lastDbFreshness = Boolean.valueOf( freshDatabase );
}
private void addUniqueUsername( List<String> list, User user )
{
if ( !list.contains( user.getUsername() ) )
{
list.add( user.getUsername() );
}
}
public void userManagerUserAdded( User user )
{
addUniqueUsername( addedUsernames, user );
}
public void userManagerUserRemoved( User user )
{
addUniqueUsername( removedUsernames, user );
}
public void userManagerUserUpdated( User user )
{
addUniqueUsername( updatedUsernames, user );
}
}