Exemplo n.º 1
0
 @Test
 public void testCreate() throws Exception {
   MeasurementType entity = new MeasurementType();
   EntityDataGenerator.generateTestDataForModelClass(entity);
   dao.persist(entity);
   assertNotNull(entity.getId());
 }
Exemplo n.º 2
0
  public List<Validations> getValidationType(String inputType, String mInstrc) {
    List<Validations> result = new ArrayList<Validations>();

    MeasurementTypeDao dao = SpringUtils.getBean(MeasurementTypeDao.class);
    List<MeasurementType> types = dao.findByTypeAndMeasuringInstruction(inputType, mInstrc);
    if (types.isEmpty()) {
      return result;
    }

    ValidationsDao vDao = SpringUtils.getBean(ValidationsDao.class);
    for (MeasurementType type : types) {
      Validations vs = vDao.find(ConversionUtils.fromIntString(type.getValidation()));
      result.add(vs);
    }
    return result;
  }
Exemplo n.º 3
0
  @Test
  public void testFindByType() throws Exception {

    String type1 = "typ1";
    String type2 = "typ2";

    MeasurementType measurementType1 = new MeasurementType();
    EntityDataGenerator.generateTestDataForModelClass(measurementType1);
    measurementType1.setType(type1);
    dao.persist(measurementType1);

    MeasurementType measurementType2 = new MeasurementType();
    EntityDataGenerator.generateTestDataForModelClass(measurementType2);
    measurementType2.setType(type1);
    dao.persist(measurementType2);

    MeasurementType measurementType3 = new MeasurementType();
    EntityDataGenerator.generateTestDataForModelClass(measurementType3);
    measurementType3.setType(type2);
    dao.persist(measurementType3);

    MeasurementType measurementType4 = new MeasurementType();
    EntityDataGenerator.generateTestDataForModelClass(measurementType4);
    measurementType4.setType(type1);
    dao.persist(measurementType4);

    List<MeasurementType> expectedResult =
        new ArrayList<MeasurementType>(
            Arrays.asList(measurementType1, measurementType2, measurementType4));
    List<MeasurementType> result = dao.findByType(type1);

    Logger logger = MiscUtils.getLogger();

    if (result.size() != expectedResult.size()) {
      logger.warn("Array sizes do not match.");
      fail("Array sizes do not match.");
    }
    for (int i = 0; i < expectedResult.size(); i++) {
      if (!expectedResult.get(i).equals(result.get(i))) {
        logger.warn("Items  do not match.");
        fail("Items  do not match.");
      }
    }
    assertTrue(true);
  }