Examples of Dto


Examples of honeycrm.client.dto.Dto

  public void testGetting() {
    final ArrayList<Key> keys = new ArrayList<Key>(COUNT);

    for (int i = 0; i < COUNT; i++) {
      final Dto c = DemoDataProvider.contact();

      final Entity e = new Entity(Contact.class.getSimpleName());
      e.setProperty("name", c.get("name"));

      keys.add(db.put(e));
    }

    final Map<Key, Entity> entities = db.get(keys);
View Full Code Here

Examples of honeycrm.client.dto.Dto

  private final ReadServiceImpl reader = new ReadServiceImpl();
  private final DeleteServiceImpl deletor = new DeleteServiceImpl();
  private final DatastoreService db = DatastoreServiceFactory.getDatastoreService();
 
  public void testDelete() {
    final Dto contact = new Dto("Contact");
    contact.set("name", "Foo");

    deletor.delete("Contact", creator.create(contact));

    final PreparedQuery pq = db.prepare(new Query("Contact"));
   
View Full Code Here

Examples of honeycrm.client.dto.Dto

 
  public void testDeleteOne() {
    final ArrayList<Long> ids = new ArrayList<Long>();
   
    for (int i=0; i<10; i++) {
      final Dto contact = new Dto("Contact");
      contact.set("name", "foo#" + i);
      ids.add(creator.create(contact));
    }
   
    deletor.delete("Contact", ids.get(0));
   
View Full Code Here

Examples of honeycrm.client.dto.Dto

import java.util.ArrayList;
import java.util.List;

public class OneToManyTest extends DatastoreTest {
  public void testCopyDtoWithOneToMany() {
    final Dto dto = new Dto();
    dto.setModule(Offering.class.getSimpleName());

    final ArrayList<Dto> uniqueServices = new ArrayList<Dto>();
    uniqueServices.add(getDtoService(UniqueService.class.getSimpleName()));

    final ArrayList<Dto> recurringServices = new ArrayList<Dto>();
    recurringServices.add(getDtoService(RecurringService.class.getSimpleName()));

    dto.set("uniqueServices", uniqueServices);
    dto.set("recurringServices", recurringServices);

    final long id = createService.create(dto);
    final Dto offering = readService.get(Offering.class.getSimpleName(), id);

    assertEquals(1, ((List<?>) offering.get("uniqueServices")).size());
    assertEquals(1, ((List<?>) offering.get("recurringServices")).size());
  }
View Full Code Here

Examples of honeycrm.client.dto.Dto

    assertEquals(1, ((List<?>) offering.get("recurringServices")).size());
  }

  public void testCopyDomainObjectWithOneToMany() {
    final int serviceCount = 1;
    final Dto offering = new Dto(Offering.class.getSimpleName());
    offering.set("uniqueServices", createAndPersistServices(serviceCount, false));
    offering.set("recurringServices", createAndPersistServices(serviceCount, true));

    final long id = createService.create(offering);
    final Dto dto = readService.get(Offering.class.getSimpleName(), id);
   
    assertNotNull(dto.get("uniqueServices"));
    assertEquals(serviceCount, ((List<?>) dto.get("uniqueServices")).size());
    assertEquals(serviceCount, ((List<?>) dto.get("recurringServices")).size());
  }
View Full Code Here

Examples of honeycrm.client.dto.Dto

  private ArrayList<Dto> createAndPersistServices(final int serviceCount, boolean uniqueServices) {
    final ArrayList<Dto> dtos = new ArrayList<Dto>();

    for (int i = 0; i < serviceCount; i++) {
      final Dto s = getService(uniqueServices);
      final long id = createService.create(s);
      dtos.add(readService.get(s.getModule(), id));
    }

    return dtos;
  }
View Full Code Here

Examples of honeycrm.client.dto.Dto

    return dtos;
  }

  private Dto getService(boolean uniqueServices) {
    final Dto service = new Dto((uniqueServices ? new UniqueService() : new RecurringService()).getClass().getSimpleName());
    service.set("name", "service" + random.nextInt());
    service.set("price", random.nextDouble());
    return service;
  }
View Full Code Here

Examples of honeycrm.client.dto.Dto

    service.set("price", random.nextDouble());
    return service;
  }

  private Dto getDtoService(final String moduleName) {
    final Dto dto = new Dto();
    dto.setModule(moduleName);
    dto.set("name", "service " + random.nextInt());
    return dto;
  }
View Full Code Here

Examples of honeycrm.client.dto.Dto

// TODO rewrite formatting tests without requiring client side GWT.create() call caused by NumberFormat/Random class.
public class FieldCurrencyTest extends TestCase {
  public void testFormatting() {
    final AbstractField field = new FieldCurrency("revenue", "Some label", "0");

    final Dto test = new Dto();
    test.set("1", 0);
    test.set("2", Integer.MAX_VALUE);
    test.set("3", Integer.MIN_VALUE);
    test.set("4", Long.MAX_VALUE);
    test.set("5", 0);
    test.set("6", Double.MAX_VALUE);
    test.set("7", Double.MIN_VALUE);
    test.set("8", "foobar");
    test.set("9", new ArrayList<String>());

    /*
     * for (final String key: test.getAllData().keySet()) { field.getWidget(View.DETAIL, test, key); }
     */
  }
 
View Full Code Here

Examples of honeycrm.client.dto.Dto

    private Dto entityToDto(final String kind, final Entity entity, final boolean isDetailView, final int resolvDepth) {
      if (null == entity) {
        return null;
      }

      final Dto dto = new Dto();
      dto.setModule(kind);
      dto.setId(entity.getKey().getId());

      for (final Map.Entry<String, Object> entry : entity.getProperties().entrySet()) {
        if ("id".equals(entry.getKey())) {
          continue; // skip this field to avoid overriding a field that has already been set
        }

        final String fieldName = entry.getKey();

        if (!isDetailView && !configuration.get(kind).isListViewField(fieldName)) {
          // skip this field because we are in the list view mode but the current field is not visible in the list view.
          // this is used to save bandwidth.
          continue;
        }

        dto.set(fieldName, (Serializable) entry.getValue());
      }

      if (resolvDepth <= 2) {
        // resolve at most 3 times e.g. Contract -> Unique Services -> Product
        resolveRelatedEntities(dto, entity, 1 + resolvDepth);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.