### Question:
VirtualMachineTemplateDAO extends
    DefaultDAOBase<Integer, VirtualMachineTemplate> { public boolean isMaster(final VirtualMachineTemplate vmtemplate) { Criteria criteria = createCriteria(sameMaster(vmtemplate)); return CollectionUtils.isEmpty(getResultList(criteria)) ? false : true; } VirtualMachineTemplateDAO();  VirtualMachineTemplateDAO(final EntityManager entityManager); List<VirtualMachineTemplate> findByEnterprise(final Enterprise enterprise); List<VirtualMachineTemplate> findByEnterpriseAndRepository(final Enterprise enterprise,
        final com.abiquo.server.core.infrastructure.Repository repository); List<VirtualMachineTemplate> findImportedByEnterprise(final Enterprise enterprise); List<VirtualMachineTemplate> findBy(final Enterprise enterprise,
        final com.abiquo.server.core.infrastructure.Repository repository, final Category category,
        final HypervisorType hypervisor); List<VirtualMachineTemplate> findBy(final Category category); List<VirtualMachineTemplate> findImportedBy(final Enterprise enterprise,
        final Category category, final HypervisorType hypervisor); VirtualMachineTemplate findByName(final String name); VirtualMachineTemplate findByPath(final Enterprise enterprise,
        final com.abiquo.server.core.infrastructure.Repository repository, final String path); boolean existWithSamePath(final Enterprise enterprise,
        final com.abiquo.server.core.infrastructure.Repository repository, final String path); List<VirtualMachineTemplate> findStatefuls(); List<VirtualMachineTemplate> findStatefulsByDatacenter(final Datacenter datacenter,
        final StatefulInclusion stateful); List<VirtualMachineTemplate> findStatefulsByDatacenter(final Datacenter datacenter,
        final VirtualDatacenter vdc, final StatefulInclusion stateful); List<VirtualMachineTemplate> findStatefulsByCategoryAndDatacenter(
        final Category category, final Datacenter datacenter, final StatefulInclusion stateful); List<VirtualMachineTemplate> findStatefulsByCategoryAndDatacenter(
        final Category category, final Datacenter datacenter, final VirtualDatacenter vdc,
        final StatefulInclusion stateful); List<VirtualMachineTemplate> findByMaster(final VirtualMachineTemplate master); boolean isMaster(final VirtualMachineTemplate vmtemplate); List<String> findIconsByEnterprise(final Integer enterpriseId);  }### Answer:
@Test public void testCheckAMasterVirtualMachineTemplateIsMaster() { VirtualMachineTemplate vi = eg().createUniqueInstance(); VirtualMachineTemplate slave = eg().createSlaveVirtualMachineTemplate(vi); List<Object> entitiesToPersist = new ArrayList<Object>(); eg().addAuxiliaryEntitiesToPersist(vi, entitiesToPersist); persistAll(ds(), entitiesToPersist, vi, slave); VirtualMachineTemplateDAO dao = createDaoForRollbackTransaction(); assertTrue(dao.isMaster(vi)); }
@Test public void testCheckVirtualMachineTemplateIsMaster() { VirtualMachineTemplate vi = eg().createUniqueInstance(); List<Object> entitiesToPersist = new ArrayList<Object>(); eg().addAuxiliaryEntitiesToPersist(vi, entitiesToPersist); persistAll(ds(), entitiesToPersist, vi); VirtualMachineTemplateDAO dao = createDaoForRollbackTransaction(); assertFalse(dao.isMaster(vi)); }
@Test public void testCheckSlaveVirtualMachineTemplateIsMaster() { VirtualMachineTemplate vi = eg().createUniqueInstance(); VirtualMachineTemplate slave = eg().createSlaveVirtualMachineTemplate(vi); List<Object> entitiesToPersist = new ArrayList<Object>(); eg().addAuxiliaryEntitiesToPersist(vi, entitiesToPersist); persistAll(ds(), entitiesToPersist, vi, slave); VirtualMachineTemplateDAO dao = createDaoForRollbackTransaction(); assertFalse(dao.isMaster(slave)); }