public boolean apply(User user) { try { Value[] poisonous = user.getProperty("poisonous"); return poisonous != null && poisonous.length == 1; } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean apply(User user) { try { Value[] cute = user.getProperty("profile/cute"); Value[] black = user.getProperty("color"); return cute != null && cute.length == 1 && cute[0].getBoolean() && !(black != null && black.length == 1 && black[0].getString().equals("black")); } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean apply(User user) { try { Value[] food = user.getProperty("profile/food"); return food != null && food.length == 1 && (food[0].getString().equals("mice") || food[0].getString().equals("nectar")); } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean evaluate(User user) { try { Value[] cute = user.getProperty("profile/cute"); Value[] black = user.getProperty("color"); return cute != null && cute.length == 1 && cute[0].getBoolean() && !(black != null && black.length == 1 && black[0].getString().equals("black")); } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean evaluate(User user) { try { Value[] poisonous = user.getProperty("poisonous"); return poisonous != null && poisonous.length == 1; } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean evaluate(User user) { try { Value[] food = user.getProperty("profile/food"); return food != null && food.length == 1 && (food[0].getString().equals("mice") || food[0].getString().equals("nectar")); } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean apply(User user) { try { Value[] food = user.getProperty("profile/food"); if (food == null || food.length != 1) { return false; } else { String value = food[0].getString(); return value.startsWith("m"); } } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean evaluate(User user) { try { Value[] food = user.getProperty("profile/food"); if (food == null || food.length != 1) { return false; } else { String value = food[0].getString(); return value.startsWith("m"); } } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean evaluate(User user) { try { Value[] cute = user.getProperty("profile/cute"); Value[] weight = user.getProperty("profile/weight"); return cute != null && cute.length == 1 && cute[0].getBoolean() && weight != null && weight.length == 1 && weight[0].getDouble() > 1000.0; } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean apply(User user) { try { Value[] cute = user.getProperty("profile/cute"); Value[] weight = user.getProperty("profile/weight"); return cute != null && cute.length == 1 && cute[0].getBoolean() && weight != null && weight.length == 1 && weight[0].getDouble() > 1000.0; } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean apply(User user) { try { Value[] weight = user.getProperty("profile/weight"); return weight != null && weight.length == 1 && weight[0].getDouble() > 2000.0; } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean evaluate(User user) { try { Value[] numberOfLegs = user.getProperty("numberOfLegs"); return numberOfLegs != null && numberOfLegs.length == 1 && numberOfLegs[0].getLong() == 8; } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean apply(User user) { try { Value[] canFly = user.getProperty("canFly"); return canFly != null && canFly.length == 1 && canFly[0].getBoolean(); } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean apply(User user) { try { Value[] numberOfLegs = user.getProperty("numberOfLegs"); return numberOfLegs != null && numberOfLegs.length == 1 && numberOfLegs[0].getLong() == 8; } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean evaluate(User user) { try { Value[] canFly = user.getProperty("canFly"); return canFly != null && canFly.length == 1 && canFly[0].getBoolean(); } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public boolean evaluate(User user) { try { Value[] weight = user.getProperty("profile/weight"); return weight != null && weight.length == 1 && weight[0].getDouble() > 2000.0; } catch (RepositoryException e) { fail(e.getMessage()); } return false; } });
public int compare(User user1, User user2) { try { Value[] weight1 = user1.getProperty("profile/weight"); assertNotNull(weight1); assertEquals(1, weight1.length); Value[] weight2 = user2.getProperty("profile/weight"); assertNotNull(weight2); assertEquals(1, weight2.length); return weight1[0].getDouble() < weight2[0].getDouble() ? -1 : 1; } catch (RepositoryException e) { fail(e.getMessage()); return 0; // Make the compiler happy } } };
public int compare(User user1, User user2) { try { Value[] weight1 = user1.getProperty("profile/weight"); assertNotNull(weight1); assertEquals(1, weight1.length); Value[] weight2 = user2.getProperty("profile/weight"); assertNotNull(weight2); assertEquals(1, weight2.length); return weight1[0].getDouble() < weight2[0].getDouble() ? -1 : 1; } catch (RepositoryException e) { fail(e.getMessage()); return 0; // Make the compiler happy } } };
@Test public void testGetNotExistingProperty() throws RepositoryException, NotExecutableException { String hint = "Fullname"; String propName = hint; int i = 0; while (user.hasProperty(propName)) { propName = hint + i; i++; } assertNull(user.getProperty(propName)); assertFalse(user.hasProperty(propName)); }
@Test public void testUserGetProperties() throws RepositoryException, NotExecutableException { Node n = getNode(user, superuser); for (PropertyIterator it = n.getProperties(); it.hasNext();) { Property p = it.nextProperty(); if (p.getDefinition().isProtected()) { assertFalse(user.hasProperty(p.getName())); assertNull(user.getProperty(p.getName())); } else { // authorizable defined property assertTrue(user.hasProperty(p.getName())); assertNotNull(user.getProperty(p.getName())); } } }