Examples of MechanicEntity


Examples of com.expositds.ars.dao.entity.user.MechanicEntity

    // Employee class properties
    mechanic.setPosition("Senior mechanic");
    mechanic.setSalary(400);

    // Create
    MechanicEntity mechanicEntity = DozerHelper.map(mechanic,
        MechanicEntity.class);
    Long id = mechanicRepository.save(mechanicEntity);

    SubsidiaryEntity subsidiaryEntity = null;
    subsidiaryEntity = subsidiaryRepository.findByName("ARS JUnit Test")
        .get(0);

    Subsidiary subsidiary = DozerHelper.map(subsidiaryEntity,
        Subsidiary.class);
    try {
      subsidiary.addEmployee(mechanic);
    } catch (EmployeeAlreadyExistsException e) {
      e.printStackTrace();
    }
    subsidiaryEntity = DozerHelper.map(subsidiary, SubsidiaryEntity.class);
    subsidiaryRepository.merge(subsidiaryEntity);

    // Read
    List<MechanicEntity> result = mechanicRepository.findBySubsidiary(
        subsidiaryEntity, null, null);

    Assert.assertEquals(1, result.size());
    Assert.assertEquals("mechanic@junit-test.com", result.iterator().next()
        .getEmail());
    Assert.assertEquals("Senior mechanic", result.iterator().next()
        .getPosition());
    Assert.assertEquals("1003010054", result.iterator().next()
        .getPliRegNo());

    // Update
    mechanicEntity = mechanicRepository.findById(id);
    mechanicEntity.setEmail("junit@test.com");
    mechanicRepository.update(mechanicEntity);

    result = mechanicRepository.findBySubsidiary(subsidiaryEntity, null,
        null);
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.