1 package org.tigris.scarab.da; 2 3 48 49 import java.util.Collection ; 50 import java.util.List ; 51 import java.util.Set ; 52 53 import org.apache.turbine.Turbine; 54 import org.tigris.scarab.test.BaseScarabTestCase; 55 import org.tigris.scarab.util.ScarabException; 56 57 62 public class AttributeAccessTest 63 extends BaseScarabTestCase 64 { 65 public void setUp() throws Exception { 66 super.setUp(); 67 Turbine.getConfiguration().setProperty("dataaccess.AttributeAccess.classname","org.tigris.scarab.da.AttributeAccess"); 68 assertNotNull(Turbine.getConfiguration().getString("dataaccess.AttributeAccess.classname")); 69 } 70 71 72 73 public void testRetrieveQueryColumnIDs() throws ScarabException 74 { 75 AttributeAccess aa = DAFactory.getAttributeAccess(); 76 String userID = "1"; 77 String listID = "1"; 78 String moduleID = "5"; 79 String artifactTypeID = "1"; 80 List ids = aa.retrieveQueryColumnIDs(userID, listID, 81 moduleID, artifactTypeID); 82 System.out.println("ids are " + ids); 83 } 85 86 90 public void OFFtestDeleteQueryColumnIDs() throws ScarabException 91 { 92 AttributeAccess aa = DAFactory.getAttributeAccess(); 93 String userID = "1"; 94 String listID = "1"; 95 String moduleID = "5"; 96 String artifactTypeID = "1"; 97 aa.deleteQueryColumnIDs(userID, listID, moduleID, artifactTypeID); 98 } 100 101 public void testRetrieveRequiredAttributeIDs() throws ScarabException 102 { 103 AttributeAccess aa = DAFactory.getAttributeAccess(); 104 String moduleID = "5"; 105 String [] artifactTypeID = {"1", "3", "5", "7", "9"}; 106 Set ids; 107 for (int i = 0; i < artifactTypeID.length; i++) 108 { 109 ids = aa.retrieveRequiredAttributeIDs(moduleID, artifactTypeID[i]); 110 assertEquals(getExpectedRequiredSize(artifactTypeID[i]), 111 ids.size()); 112 } 113 } 114 115 private int getExpectedRequiredSize(String artifactTypeID) 116 117 { 118 int expectedSize = 0; 119 switch (Integer.parseInt(artifactTypeID)) 120 { 121 case 1: expectedSize = 4;break; 122 case 3: expectedSize = 4;break; 123 case 5: expectedSize = 2;break; 124 case 7: expectedSize = 2;break; 125 case 9: expectedSize = 2;break; 126 } 127 return expectedSize; 128 } 129 130 public void testRetrieveQuickSearchAttributeIDs() throws ScarabException 131 { 132 AttributeAccess aa = DAFactory.getAttributeAccess(); 133 String moduleID = "5"; 134 String artifactTypeID = "1"; 135 Set ids = aa.retrieveQuickSearchAttributeIDs(moduleID, artifactTypeID); 136 } 138 139 public void testRetrieveActiveAttributeOMs() throws ScarabException 140 { 141 AttributeAccess aa = DAFactory.getAttributeAccess(); 142 String moduleID = "5"; 143 boolean isOrdered = false; 144 String [] artifactTypeID = {"1", "3", "5", "7", "9"}; 145 Collection oms; 146 for (int i = 0; i < artifactTypeID.length; i++) 147 { 148 oms = aa.retrieveActiveAttributeOMs(moduleID, artifactTypeID[i], 149 isOrdered); 150 assertEquals(getExpectedActiveSize(artifactTypeID[i]), oms.size()); 151 } 152 } 153 154 private int getExpectedActiveSize(String artifactTypeID) 155 156 { 157 int expectedSize = 0; 158 switch (Integer.parseInt(artifactTypeID)) 159 { 160 case 1: expectedSize = 12;break; 162 case 3: expectedSize = 11;break; 163 case 5: expectedSize = 9;break; 164 case 7: expectedSize = 9;break; 165 case 9: expectedSize = 9;break; 166 } 167 return expectedSize; 168 } 169 170 public void testRetrieveDefaultTextAttributeID() throws ScarabException 171 { 172 AttributeAccess aa = DAFactory.getAttributeAccess(); 173 String moduleID = "5"; 174 String artifactTypeID = "1"; 175 String id = aa.retrieveDefaultTextAttributeID(moduleID, 176 artifactTypeID); 177 } 179 180 public void testRetrieveFirstActiveTextAttributeID() throws ScarabException 181 { 182 AttributeAccess aa = DAFactory.getAttributeAccess(); 183 String moduleID = "5"; 184 String artifactTypeID = "1"; 185 String id = aa.retrieveFirstActiveTextAttributeID(moduleID, 186 artifactTypeID); 187 } 189 } 190 | Popular Tags |