@@ -0,0 +1,3171 @@
+/**%0A * Copyright (c) 2002-2022, City of Paris%0A * All rights reserved.%0A *%0A * Redistribution and use in source and binary forms, with or without%0A * modification, are permitted provided that the following conditions%0A * are met:%0A *%0A *  1. Redistributions of source code must retain the above copyright notice%0A *     and the following disclaimer.%0A *%0A *  2. Redistributions in binary form must reproduce the above copyright notice%0A *     and the following disclaimer in the documentation and/or other materials%0A *     provided with the distribution.%0A *%0A *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its%0A *     contributors may be used to endorse or promote products derived from%0A *     this software without specific prior written permission.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22%0A * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE%0A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE%0A * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE%0A * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR%0A * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF%0A * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS%0A * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN%0A * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)%0A * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE%0A * POSSIBILITY OF SUCH DAMAGE.%0A *%0A * License 1.0%0A */%0Apackage fr.paris.lutece.portal.service.event;%0A%0Aimport java.util.function.Consumer;%0A%0Aimport fr.paris.lutece.portal.business.event.LuteceUserEvent;%0Aimport fr.paris.lutece.portal.service.datastore.DatastoreService;%0Aimport fr.paris.lutece.portal.service.security.MokeLuteceAuthentication;%0Aimport fr.paris.lutece.portal.service.security.MokeLuteceUser;%0Aimport fr.paris.lutece.test.LuteceTestCase;%0A%0A/**%0A * DatastoreService Test%0A */%0Apublic class LuteceUserEventManagerTest extends LuteceTestCase%0A%7B%0A%09private static final String USER_NAME = %22user-test%22;%0A%09private static final String KEY1 = %22key_LuteceUserEventManagerTest%22;%0A    private static final String VALUE_DEFAULT = %22default_value%22;%0A    private static final String NEW_VALUE = %22new_value%22;%0A%0A    public void test( )%0A    %7B%0A    %09DatastoreService.setDataValue( KEY1, VALUE_DEFAULT );%0A  %0A    %09MokeLuteceUser user = new MokeLuteceUser( USER_NAME, new MokeLuteceAuthentication( ) );%0A%0A    %09// listener consumer function %0A    %09Consumer%3CLuteceUserEvent%3E myfuncion = (LuteceUserEvent event) -%3E %7B%0A    %09%09DatastoreService.setDataValue( KEY1, NEW_VALUE );%0A    %09%7D;%0A%0A    %09// register listener%0A    %09LuteceUserEventManager.getInstance( ).register( %22mylistener%22 , myfuncion );%0A%0A    %09// noptify an event%0A    %09LuteceUserEventManager.getInstance( ).notifyListeners( new LuteceUserEvent( user, LuteceUserEvent.EventType.LOGIN_SUCCESSFUL ) );%0A%0A    %09// check if the datastore value has been changed%0A    %09String strValue = DatastoreService.getDataValue( KEY1, VALUE_DEFAULT );%0A    %09assertEquals( strValue, NEW_VALUE );%0A%0A    %09DatastoreService.removeData( KEY1 );%0A    %7D%0A%7D%0A

add test for Lutece event management