1 19 20 package com.sslexplorer.applicationshortctus; 21 22 import java.util.Calendar ; 23 import java.util.Collections ; 24 import java.util.List ; 25 26 import org.junit.BeforeClass; 27 import org.junit.Test; 28 29 import com.sslexplorer.applications.ApplicationShortcut; 30 import com.sslexplorer.applications.ApplicationShortcutDatabase; 31 import com.sslexplorer.applications.ApplicationShortcutDatabaseFactory; 32 import com.sslexplorer.applications.ApplicationsPlugin; 33 import com.sslexplorer.applications.DefaultApplicationShortcut; 34 import com.sslexplorer.policyframework.ResourceType; 35 import com.sslexplorer.testcontainer.policyframework.AbstractTestPolicyEnabledResource; 36 37 public class ApplicationShortcutsTests extends AbstractTestPolicyEnabledResource<ApplicationShortcut> { 38 39 @BeforeClass 40 public static void oneTimeSetUp() throws Exception { 41 setUp("sslexplorer-agent,sslexplorer-community-applications,sslexplorer-community-tunnels"); 42 } 43 44 @Override 45 public ApplicationShortcut getEmptyResource() throws Exception { 46 Calendar calendar = Calendar.getInstance(); 47 return new DefaultApplicationShortcut(getDefaultRealm().getRealmID(), -1, "", "", calendar, calendar, "", Collections.<String ,String >emptyMap()); 48 } 49 50 @Override 51 public ApplicationShortcut getNormalResource() throws Exception { 52 Calendar calendar = Calendar.getInstance(); 53 return new DefaultApplicationShortcut(getDefaultRealm().getRealmID(), -1, "RDP Name", "This is a RDP Description", calendar, calendar, "RDP", Collections.<String ,String >emptyMap()); 54 } 55 56 @Override 57 public ApplicationShortcut getNullResource() throws Exception { 58 Calendar calendar = Calendar.getInstance(); 59 return new DefaultApplicationShortcut(getDefaultRealm().getRealmID(), -1, null, null, calendar, calendar, null, Collections.<String ,String >emptyMap()); 60 } 61 62 @Override 63 public ApplicationShortcut createResource(ApplicationShortcut resource) throws Exception { 64 return getApplicationShortcutService().getShortcut( 65 getApplicationShortcutService().createApplicationShortcut(resource.getApplication(), resource.getResourceName(), 66 resource.getResourceDescription(), resource.getParameters(), resource.getRealmID())); 67 } 68 69 @Override 70 public ApplicationShortcut updateResource(ApplicationShortcut resource) throws Exception { 71 getApplicationShortcutService().updateApplicationShortcut(resource.getResourceId(), resource.getResourceName(), 72 resource.getResourceDescription(), resource.getParameters()); 73 return getApplicationShortcutService().getShortcut(resource.getResourceId()); 74 } 75 76 @Override 77 public List <ApplicationShortcut> getAllResources() throws Exception { 78 return getApplicationShortcutService().getShortcuts(); 79 } 80 81 @Override 82 public ResourceType getResourceType() throws Exception { 83 return ApplicationsPlugin.APPLICATION_SHORTCUT_RESOURCE_TYPE; 84 } 85 86 @Override 87 public ApplicationShortcut deleteResource(ApplicationShortcut resource) throws Exception { 88 ApplicationShortcut shortcut = ApplicationShortcutDatabaseFactory.getInstance().getShortcut(resource.getResourceId()); 89 getApplicationShortcutService().deleteShortcut(shortcut.getResourceId()); 90 return shortcut; 91 } 92 93 @Override 94 public ApplicationShortcut getResource(ApplicationShortcut resource) throws Exception { 95 return getApplicationShortcutService().getShortcut(resource.getResourceId()); 96 } 97 98 protected static ApplicationShortcutDatabase getApplicationShortcutService() throws Exception { 99 return ApplicationShortcutDatabaseFactory.getInstance(); 100 } 101 102 @Override 103 public void createNullResource() throws Exception { 104 } 105 106 @Test 107 public void mustHaveTests() { 108 } 109 } | Popular Tags |