OresHelper { public static OLATResourceable createOLATResourceableInstance(final String type, final Long key) { if (key == null) throw new AssertException("key may not be null; type = " + type); if (type.length() > ORES_TYPE_LENGTH) throw new AssertException("Olatresource type may not exceed " + ORES_TYPE_LENGTH + " chars: type=" + type); return new OLATResourceable() { @Override public String getResourceableTypeName() { return type; } @Override public Long getResourceableId() { return key; } }; }  static OLATResourceable createOLATResourceableInstance(final String type, final Long key); static OLATResourceable createOLATResourceableType(final String type, final String subtype); static OLATResourceable createOLATResourceableType(final String type); static OLATResourceable createOLATResourceableType(Class clazz); static OLATResourceable createOLATResourceableInstance(Class aClass, final Long key); static String createStringRepresenting(OLATResourceable ores, String subKey); static String createStringRepresenting(OLATResourceable ores); static OLATResourceable lookupType(Class aClass); static String calculateTypeName(Class aClass); static String calculateTypeName(Class aClass, String subType); static boolean isOfType(OLATResourceable ores, Class aClass); static OLATResourceable lookupType(Class aClass, String subType); static boolean equals(OLATResourceable a, OLATResourceable b); static OLATResourceable createOLATResourceableTypeWithoutCheck(String type); static OLATResourceable createOLATResourceableInstanceWithoutCheck(final String type, final Long key); static final int ORES_TYPE_LENGTH; }
@Test(expected = AssertException.class) public void createOLATResourceableInstance_ForClassAndNullKey() { OresHelper.createOLATResourceableInstance(classInstance, null); }
@Test public void createOLATResourceableInstance_ForClass() { OLATResourceable resourceable = OresHelper.createOLATResourceableInstance(classInstance, DEFAULT_KEY); assertNotNull(resourceable); assertNotNull(resourceable.getResourceableTypeName()); assertEquals(resourceable.getResourceableTypeName(), CLASS_NAME_NO_PACKAGE); assertNotNull(resourceable.getResourceableId()); assertEquals(resourceable.getResourceableId(), DEFAULT_KEY); }
@Test(expected = AssertException.class) public void createOLATResourceableInstance_ForStringAndNullKey() { OresHelper.createOLATResourceableInstance(CLASS_NAME_NO_PACKAGE, null); }
@Test public void createOLATResourceableInstance_ForString() { OLATResourceable resourceable = OresHelper.createOLATResourceableInstance(CLASS_NAME_NO_PACKAGE, DEFAULT_KEY); assertNotNull(resourceable); assertNotNull(resourceable.getResourceableTypeName()); assertEquals(resourceable.getResourceableTypeName(), CLASS_NAME_NO_PACKAGE); assertNotNull(resourceable.getResourceableId()); assertEquals(resourceable.getResourceableId(), DEFAULT_KEY); }