Michael Pasternak has posted comments on this change. Change subject: resatpi: Eliminate Exceptions in Mapper Tests ......................................................................
Patch Set 1: (5 comments) .................................................... Commit Message Line 3: AuthorDate: 2013-09-30 13:43:22 +0300 Line 4: Commit: Ori Liel <[email protected]> Line 5: CommitDate: 2013-09-30 13:50:01 +0300 Line 6: Line 7: resatpi: Eliminate Exceptions in Mapper Tests more details please Line 8: Line 9: Change-Id: I84cabed0ff38196d8fd57d2f72ffdfe213f2ffed .................................................... File backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/MappingTestHelper.java Line 19: private static final String SLAVES_PLURAL = "Slaves"; Line 20: private static final String FLOPPY_SINGLE = "Floppy"; Line 21: private static final String FLOPPIES_PLURAL = "Floppies"; Line 22: private static final String NIC_SINGLE = "NIC"; Line 23: private static final String NICS_PLURAL = "Nics"; worth doing ecualIgnorecase() rather than maintaining exceptional case-based names?! Line 24: private static final String XML_GREGORIAN_CALENDAR = "javax.xml.datatype.XMLGregorianCalendar"; Line 25: private static final String SET_ROOT = "set"; Line 26: private static final String GET_ROOT = "get"; Line 27: Line 127: Line 128: private static void descend(Method method, Object model, List<Class<?>> seen, int level) throws Exception { Line 129: Class<?> type = method.getParameterTypes()[0]; Line 130: Object child; Line 131: if (type.getName().equals(XML_GREGORIAN_CALENDAR)) { please put this (exceptional treatment) where all other treatment of same kind are done Line 132: child = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar(1111, 10, 29)); Line 133: } else { Line 134: child = type.newInstance(); Line 135: } Line 207: private static Class<?> coPackaged(Object model, String elementType) throws ClassNotFoundException { Line 208: String packageRoot = model.getClass().getPackage().getName() + "."; Line 209: try { Line 210: // Consider special case: "Usages" contains a list of Strings, not 'Usage' elements. Line 211: return elementType.equals("Usages") ? String.class : please take this code out to dedicated method (addressing exceptions) Line 212: Class.forName(packageRoot + singular(elementType)); Line 213: } catch (ClassNotFoundException cnf) { Line 214: try { Line 215: return Class.forName(packageRoot + elementType); Line 224: // Consider exceptional cases: Line 225: // 'Nics' is plural of 'NIC' (uppercase) Line 226: // 'Floppies' is plural of 'Floppy' (not 'Floppie') Line 227: // 'Slaves' is plural of 'HostNIC' (we don't have a 'Slave' entity) Line 228: return s.equals(NICS_PLURAL) ? NIC_SINGLE : s.equals(FLOPPIES_PLURAL) ? FLOPPY_SINGLE : s.equals(SLAVES_PLURAL) ? SLAVE_SINGLE : same Line 229: s.endsWith("s") ? s.substring(0, Line 230: s.length() - 1) : s; Line 231: } Line 232: -- To view, visit http://gerrit.ovirt.org/19673 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I84cabed0ff38196d8fd57d2f72ffdfe213f2ffed Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ori Liel <[email protected]> Gerrit-Reviewer: Michael Pasternak <[email protected]> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
