@@ -0,0 +1,2933 @@
+package org.datacite.mds.service.impl;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.Collection;%0Aimport java.util.Date;%0A%0Aimport org.apache.commons.lang.time.DateUtils;%0Aimport org.datacite.mds.domain.AllocatorOrDatacentre;%0Aimport org.datacite.mds.service.MagicAuthStringService;%0Aimport org.datacite.mds.test.Utils;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.powermock.api.easymock.PowerMock;%0Aimport org.powermock.core.classloader.annotations.PowerMockIgnore;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0A%0A@RunWith(PowerMockRunner.class)%0A@PowerMockIgnore( %7B %22javax.*%22, %22org.apache.log4j.*%22 %7D)%0A@PrepareForTest( %7B MagicAuthStringServiceImpl.class %7D)%0Apublic class MagicAuthStringImplTest %7B%0A    %0A    MagicAuthStringService service = new MagicAuthStringServiceImpl();%0A    %0A    AllocatorOrDatacentre user = Utils.createAllocator(%22AL%22);%0A    %0A    Date today = new Date();%0A    Date tomorrow = DateUtils.addDays(today, 1);%0A    Date yesterday = DateUtils.addDays(today, -1);%0A    Date anotherDay = DateUtils.addDays(today, 2);%0A    %0A    @Test%0A    public void testGetValidAuthStrings() %7B%0A        setDate(today);%0A        String authToday = service.getCurrentAuthString(user);%0A%0A        setDate(yesterday);%0A        String authYesterday = service.getCurrentAuthString(user);%0A        %0A        setDate(today);%0A        Collection%3CString%3E validAuthStrings = service.getValidAuthStrings(user);%0A        %0A        assertEquals(2, validAuthStrings.size());%0A        assertTrue(validAuthStrings.contains(authToday));%0A        assertTrue(validAuthStrings.contains(authYesterday));%0A    %7D%0A    %0A    @Test%0A    public void testIsValidAuthString() %7B%0A        setDate(today);%0A        String auth = service.getCurrentAuthString(user);%0A        %0A        setDate(today);%0A        assertTrue(service.isValidAuthString(user, auth));%0A        %0A        setDate(tomorrow);%0A        assertTrue(service.isValidAuthString(user, auth));%0A        %0A        setDate(yesterday);%0A        assertFalse(service.isValidAuthString(user, auth));%0A        %0A        setDate(anotherDay);%0A        assertFalse(service.isValidAuthString(user, auth));%0A    %7D%0A    %0A    @Test %0A    public void testNull() %7B%0A        assertNull(service.getCurrentAuthString(null));%0A        assertFalse(service.isValidAuthString(null, %22foobar%22));%0A        assertFalse(service.isValidAuthString(user, null));%0A        assertTrue(service.getValidAuthStrings(null).isEmpty());%0A    %7D%0A    %0A    %0A    private void setDate(Date date) %7B%0A        try %7B%0A            PowerMock.resetAll();%0A            PowerMock.expectNew(Date.class).andReturn(date);%0A            PowerMock.replayAll();%0A        %7D catch (Exception e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%7D%0A

add test for MagicAuthStringImpl