List of usage examples for org.apache.commons.lang.builder ToStringBuilder reflectionToString
public static String reflectionToString(Object object)
Forwards to ReflectionToStringBuilder
.
From source file:org.up4j.APITest.java
/** * Test of getFeed method, of class API. *//* w ww . ja v a2 s .c o m*/ @Test public void testGetTimeline() throws Exception { System.out.println("getTimeline"); Iterator<List<Activity>> timeline = api.getFeed(); assertNotNull(timeline); if (timeline.hasNext()) { List<Activity> page = timeline.next(); for (Activity activity : page) { System.out.println(ToStringBuilder.reflectionToString(activity)); } } }
From source file:org.up4j.APITest.java
private <T> void checkSettings(T current, T updated) throws Exception { System.out.println(ToStringBuilder.reflectionToString(current)); System.out.println(ToStringBuilder.reflectionToString(updated)); assertTrue(OBJECT_MAPPER.convertValue(current, JsonNode.class) .equals(OBJECT_MAPPER.convertValue(updated, JsonNode.class))); }
From source file:org.up4j.APITest.java
@Test public void testGetMoves() throws Exception { System.out.println("getMoves"); Iterator<List<Move>> moves = api.getMoves(); assertNotNull(moves);//www . j av a2 s . c o m System.out.println(jsonResponseHolder.getJson().toString()); if (moves.hasNext()) { List<Move> page = moves.next(); for (Move move : page) { System.out.println(ToStringBuilder.reflectionToString(move)); } if (!page.isEmpty()) { Move move = page.get(0); Move getById = api.getMove(move.getXid()); assertNotNull(getById); assertEquals(move.getXid(), getById.getXid()); List<Tick> ticks = api.getTicks(move.getXid()); assertNotNull(ticks); for (Tick tick : ticks) { System.out.println(ToStringBuilder.reflectionToString(tick)); } List<TimeSlice> snapshot = api.getMoveSnapshot(move.getXid()); for (TimeSlice timeSlice : snapshot) { System.out.println(ToStringBuilder.reflectionToString(timeSlice)); } } } }
From source file:org.up4j.APITest.java
@Test public void testGetSleeps() throws Exception { System.out.println("getSleeps"); Iterator<List<Sleep>> sleeps = api.getSleeps(); assertNotNull(sleeps);/*w w w .j av a2 s .co m*/ System.out.println(jsonResponseHolder.getJson().toString()); if (sleeps.hasNext()) { List<Sleep> page = sleeps.next(); for (Sleep sleep : page) { System.out.println(ToStringBuilder.reflectionToString(sleep)); } if (!page.isEmpty()) { Sleep sleep = page.get(0); Sleep getById = api.getSleep(sleep.getXid()); assertNotNull(getById); assertEquals(sleep.getXid(), getById.getXid()); List<TimeSlice> snapshot = api.getSleepSnapshot(sleep.getXid()); for (TimeSlice timeSlice : snapshot) { System.out.println(ToStringBuilder.reflectionToString(timeSlice)); } } } }
From source file:org.up4j.APITest.java
@Test public void testGetMeals() throws Exception { System.out.println("getMeals"); Iterator<List<Meal>> meals = api.getMeals(); assertNotNull(meals);/*from w ww .j a v a2 s . c o m*/ System.out.println(jsonResponseHolder.getJson().toString()); if (meals.hasNext()) { List<Meal> page = meals.next(); for (Meal meal : page) { System.out.println(ToStringBuilder.reflectionToString(meal)); } if (!page.isEmpty()) { Meal meal = page.get(0); Meal getById = api.getMeal(meal.getXid()); assertNotNull(getById); assertEquals(meal.getXid(), getById.getXid()); List<FoodItem> items = getById.getItems(); if (items != null) { for (FoodItem foodItem : items) { System.out.println(ToStringBuilder.reflectionToString(foodItem)); } } } } }
From source file:org.xlcloud.service.dao.JpaVirtualClusterDefinitionsDao.java
/** {@inheritDoc} */ @Override//ww w. ja v a 2 s. c o m public List<VirtualClusterDefinitionModel> findByTypeAndTags(Long accountId, String type, Set<String> tags, boolean paged) { if (LOG.isDebugEnabled()) { LOG.debug("finding vc definitions with type id: " + type + " and following tag ids:" + ToStringBuilder.reflectionToString(tags)); } CriteriaBuilder criteriaBuilder = getCriteriaBuilder(); CriteriaQuery<Tuple> query = criteriaBuilder.createTupleQuery(); Root<VirtualClusterDefinitionModel> vcDefRoot = query.from(VirtualClusterDefinitionModel.class); Predicate typePredicate = criteriaBuilder.equal(vcDefRoot.get(VirtualClusterDefinitionModel_.type), type); Predicate tagsPredicate = vcDefRoot.get(VirtualClusterDefinitionModel_.tags).in(tags); boolean skipTagsJoin = tags.isEmpty(); Predicate predicate = skipTagsJoin ? typePredicate : criteriaBuilder.and(typePredicate, tagsPredicate); Predicate scopePredicate; if (accountId != null) { Predicate accountPredicate = criteriaBuilder .equal(vcDefRoot.get(VirtualClusterDefinitionModel_.accountId), accountId); Predicate privatePredicate = criteriaBuilder .equal(vcDefRoot.get(VirtualClusterDefinitionModel_.catalogScope), CatalogScope.PRIVATE); scopePredicate = criteriaBuilder.and(accountPredicate, privatePredicate); } else { scopePredicate = criteriaBuilder.equal(vcDefRoot.get(VirtualClusterDefinitionModel_.catalogScope), CatalogScope.PUBLIC); } predicate = criteriaBuilder.and(predicate, scopePredicate); query.multiselect(vcDefRoot, criteriaBuilder.count(vcDefRoot)); query.where(predicate); query.groupBy(vcDefRoot); if (!skipTagsJoin) { query.having(criteriaBuilder.equal(criteriaBuilder.count(vcDefRoot), tags.size())); } List<Tuple> list = getResultList(query, vcDefRoot, paged); List<VirtualClusterDefinitionModel> results = new LinkedList<VirtualClusterDefinitionModel>(); for (Tuple t : list) { results.add((VirtualClusterDefinitionModel) t.get(0)); } return results; }
From source file:org.xlcloud.service.impl.AccountsImpl.java
private VirtualClusterDefinitions getVirtualClusterDefinitionsForApps(Long accountId, List<Long> appIds) { LOG.info("Getting VirtualClusterDefinition for applications: [ " + ToStringBuilder.reflectionToString(appIds) + " ]"); Set<String> tags = applicationsManager.getTagsForApplications(new HashSet<Long>(appIds)); String type = applicationsManager.getCommonTypeForApplications(new HashSet<Long>(appIds)); return vcDefsManager.listByTypeAndTags(accountId, type, tags); }
From source file:org.xlcloud.service.impl.AccountsImpl.java
private VirtualClusterDefinitions getVirtualClusterDefinitionsForTypeAndTags(Long accountId, String type, List<String> tags) { LOG.info("Getting VirtualClusteDefinition by type: [ " + type + " ], and tags: [ " + ToStringBuilder.reflectionToString(tags) + " ]."); return vcDefsManager.listByTypeAndTags(accountId, type, new HashSet<String>(tags)); }
From source file:org.xlcloud.service.impl.VirtualClusterDefinitionsImpl.java
private VirtualClusterDefinitions getVirtualClusterDefinitionsForApps(List<Long> appIds) { LOG.info("Getting VirtualClusterDefinition for applications: [ " + ToStringBuilder.reflectionToString(appIds) + " ]"); Set<String> tags = applicationsManager.getTagsForApplications(new HashSet<Long>(appIds)); String type = applicationsManager.getCommonTypeForApplications(new HashSet<Long>(appIds)); return vcDefsManager.listPublicByTypeAndTags(type, tags); }
From source file:org.xlcloud.service.impl.VirtualClusterDefinitionsImpl.java
private VirtualClusterDefinitions getVirtualClusterDefinitionsForTypeAndTags(String type, List<String> tags) { LOG.info("Getting VirtualClusterDefinition by type: [ " + type + " ], and tags: [ " + ToStringBuilder.reflectionToString(tags) + " ]."); return vcDefsManager.listPublicByTypeAndTags(type, new HashSet<String>(tags)); }