@Test void testGetObjectIdentities2() { Map<String, Object> paramMap = new HashMap<>(); paramMap.put("classId", "classId"); List<Map<String, Object>> result = new ArrayList<>(); Map<String, Object> result1 = new HashMap<>(); result1.put("object_id_identity", "test1"); result1.put("class", "classId"); Map<String, Object> result2 = new HashMap<>(); result2.put("object_id_identity", "test2"); result2.put("class", "classId"); result.addAll(Arrays.asList(result1, result2)); doReturn(new Integer(12)) .when(jdbcTemplate) .queryForObject( "SELECT COUNT( DISTINCT acl_object_identity.object_id_identity) FROM acl_object_identity LEFT JOIN acl_class ON acl_object_identity.object_id_class = acl_class.id LEFT JOIN acl_entry ON acl_entry.acl_object_identity = acl_object_identity.id LEFT JOIN acl_sid ON acl_entry.sid = acl_sid.id WHERE acl_class.class = :classId", paramMap, Integer.class); Map<String, Object> paramMap2 = new HashMap<>(); paramMap2.put("classId", "classId"); doReturn(result) .when(jdbcTemplate) .queryForList( "SELECT DISTINCT acl_object_identity.object_id_identity, acl_class.class FROM acl_object_identity LEFT JOIN acl_class ON acl_object_identity.object_id_class = acl_class.id LEFT JOIN acl_entry ON acl_entry.acl_object_identity = acl_object_identity.id LEFT JOIN acl_sid ON acl_entry.sid = acl_sid.id WHERE acl_class.class = :classId ORDER BY acl_object_identity.object_id_identity ASC", paramMap2); ObjectIdentity identity1 = mock(ObjectIdentity.class); ObjectIdentity identity2 = mock(ObjectIdentity.class); doReturn(identity1).when(entityHelper).getObjectIdentity("classId", "test1"); doReturn(identity2).when(entityHelper).getObjectIdentity("classId", "test2"); List<ObjectIdentity> expected = Arrays.asList(identity1, identity2); assertEquals(expected, objectIdentityService.getObjectIdentities("classId")); }
@Override public List<ObjectIdentity> getObjectIdentities(String classId) { int rowCount = getNrOfObjectIdentities(classId); if (rowCount > MAX_RESULTS) { throw new UnsupportedOperationException( "Unfiltered select on object identities not supported for classes with more than '" + MAX_RESULTS + "' rows."); } Map<String, Object> paramMap = new HashMap<>(); paramMap.put(CLASS_ID, classId); List<Map<String, Object>> result = getTemplate().queryForList(SQL_SELECT_OBJECT_IDENTITIES + WHERE_CLASS + ORDER_BY, paramMap); return parseToStringList(result); }
ObjectIdentityServiceImpl implements ObjectIdentityService { @Override public List<ObjectIdentity> getObjectIdentities(String classId) { int rowCount = getNrOfObjectIdentities(classId); if (rowCount > MAX_RESULTS) { throw new UnsupportedOperationException( "Unfiltered select on object identities not supported for classes with more than '" + MAX_RESULTS + "' rows."); } Map<String, Object> paramMap = new HashMap<>(); paramMap.put(CLASS_ID, classId); List<Map<String, Object>> result = getTemplate().queryForList(SQL_SELECT_OBJECT_IDENTITIES + WHERE_CLASS + ORDER_BY, paramMap); return parseToStringList(result); } }
ObjectIdentityServiceImpl implements ObjectIdentityService { @Override public List<ObjectIdentity> getObjectIdentities(String classId) { int rowCount = getNrOfObjectIdentities(classId); if (rowCount > MAX_RESULTS) { throw new UnsupportedOperationException( "Unfiltered select on object identities not supported for classes with more than '" + MAX_RESULTS + "' rows."); } Map<String, Object> paramMap = new HashMap<>(); paramMap.put(CLASS_ID, classId); List<Map<String, Object>> result = getTemplate().queryForList(SQL_SELECT_OBJECT_IDENTITIES + WHERE_CLASS + ORDER_BY, paramMap); return parseToStringList(result); } ObjectIdentityServiceImpl(JdbcTemplate jdbcTemplate, EntityHelper entityHelper);   ObjectIdentityServiceImpl(NamedParameterJdbcTemplate jdbcTemplate, EntityHelper entityHelper); }
ObjectIdentityServiceImpl implements ObjectIdentityService { @Override public List<ObjectIdentity> getObjectIdentities(String classId) { int rowCount = getNrOfObjectIdentities(classId); if (rowCount > MAX_RESULTS) { throw new UnsupportedOperationException( "Unfiltered select on object identities not supported for classes with more than '" + MAX_RESULTS + "' rows."); } Map<String, Object> paramMap = new HashMap<>(); paramMap.put(CLASS_ID, classId); List<Map<String, Object>> result = getTemplate().queryForList(SQL_SELECT_OBJECT_IDENTITIES + WHERE_CLASS + ORDER_BY, paramMap); return parseToStringList(result); } ObjectIdentityServiceImpl(JdbcTemplate jdbcTemplate, EntityHelper entityHelper);   ObjectIdentityServiceImpl(NamedParameterJdbcTemplate jdbcTemplate, EntityHelper entityHelper); @Override List<ObjectIdentity> getObjectIdentities(String classId); @Override Integer getNrOfObjectIdentities(String classId); @Override Integer getNrOfObjectIdentities(String classId, Set<Sid> sids); @Override List<ObjectIdentity> getObjectIdentities(String classId, int limit, int offset); @Override List<ObjectIdentity> getObjectIdentities(
      String classId, Set<Sid> sids, int limit, int offset); @Override List<ObjectIdentity> getObjectIdentities(String classId, Set<Sid> sids); }
ObjectIdentityServiceImpl implements ObjectIdentityService { @Override public List<ObjectIdentity> getObjectIdentities(String classId) { int rowCount = getNrOfObjectIdentities(classId); if (rowCount > MAX_RESULTS) { throw new UnsupportedOperationException( "Unfiltered select on object identities not supported for classes with more than '" + MAX_RESULTS + "' rows."); } Map<String, Object> paramMap = new HashMap<>(); paramMap.put(CLASS_ID, classId); List<Map<String, Object>> result = getTemplate().queryForList(SQL_SELECT_OBJECT_IDENTITIES + WHERE_CLASS + ORDER_BY, paramMap); return parseToStringList(result); } ObjectIdentityServiceImpl(JdbcTemplate jdbcTemplate, EntityHelper entityHelper);   ObjectIdentityServiceImpl(NamedParameterJdbcTemplate jdbcTemplate, EntityHelper entityHelper); @Override List<ObjectIdentity> getObjectIdentities(String classId); @Override Integer getNrOfObjectIdentities(String classId); @Override Integer getNrOfObjectIdentities(String classId, Set<Sid> sids); @Override List<ObjectIdentity> getObjectIdentities(String classId, int limit, int offset); @Override List<ObjectIdentity> getObjectIdentities(
      String classId, Set<Sid> sids, int limit, int offset); @Override List<ObjectIdentity> getObjectIdentities(String classId, Set<Sid> sids); static final Integer MAX_RESULTS; static final String OBJECT_ID_IDENTITY; static final String CLASS; static final String CLASS_ID; static final String LIMIT; static final String OFFSET; static final String SIDS; }