/** Test the controller completeEditModel method. */
  @SuppressWarnings("unchecked")
  @Test
  public void testCompleteEditModel() {
    NanomaterialController controller = new NanomaterialController();
    GenericServiceMockup<Container> containerService = new GenericServiceMockup<Container>();
    controller.setContainerService(containerService);
    GenericServiceMockup<ContainerSubcategory> containerSubcategoryService =
        new GenericServiceMockup<ContainerSubcategory>();
    controller.setContainerSubcategoryService(containerSubcategoryService);
    GenericServiceMockup<ContainerType> containerTypeService =
        new GenericServiceMockup<ContainerType>();
    controller.setContainerTypeService(containerTypeService);
    GenericServiceMockup<FillPattern> fillPatternService = new GenericServiceMockup<FillPattern>();
    controller.setFillPatternService(fillPatternService);
    GenericServiceMockup<Location> locationService = new GenericServiceMockup<Location>();
    controller.setLocationService(locationService);
    GenericServiceMockup<Organization> organizationService =
        new GenericServiceMockup<Organization>();
    controller.setOrganizationService(organizationService);
    GenericServiceMockup<Person> personService = new GenericServiceMockup<Person>();
    controller.setPersonService(personService);
    QuantityHelperMockup quantityHelper = new QuantityHelperMockup();
    controller.setQuantityHelper(quantityHelper);
    GenericServiceMockup<Specimen> specimenService = new GenericServiceMockup<Specimen>();
    controller.setMainService((GenericServiceMockup) specimenService);
    GenericServiceMockup<Type> typeService = new GenericServiceMockup<Type>();
    controller.setTypeService(typeService);
    GenericServiceMockup<StandardUnit> unitService = new GenericServiceMockup<StandardUnit>();
    controller.setUnitService(unitService);

    GenericServiceMockup<ChemicalCompound> chemicalCompoundService =
        new GenericServiceMockup<ChemicalCompound>();
    controller.setChemicalCompoundService(chemicalCompoundService);

    ModelAndView model = new ModelAndView();
    NanomaterialForm form = new NanomaterialForm();
    model.addObject("form", form);
    ModelAndView result = controller.completeEditModel(model, Locale.US);
    assertEquals("Wrong model returned", model, result);
    String containerQueryName = Container.class.getName() + ".findContainersForSpecimenCreation";
    CRUDAssert.assertNamedQuery(result, containerService, 0, containerQueryName, "containers");
    CRUDAssert.assertFindAll(
        containerSubcategoryService,
        ContainerSubcategory.class,
        "name",
        "containerSubcategories",
        result);
    CRUDAssert.assertFindAll(
        containerTypeService, ContainerType.class, "name", "containerTypes", result);
    CRUDAssert.assertFindAll(fillPatternService, FillPattern.class, "name", "fillPatterns", result);
    CRUDAssert.assertFindAll(specimenService, Specimen.class, "name", "specimens", result);
    CRUDAssert.assertFindAll(
        organizationService, Organization.class, "name", "organizations", result);
    CRUDAssert.assertFindAll(personService, Person.class, "familyName", "persons", result);
    CRUDAssert.assertFindAll(locationService, Location.class, "name", "locations", result);
    CRUDAssert.assertFindAll(
        chemicalCompoundService, ChemicalCompound.class, "name", "chemicalCompounds", result);
    CRUDAssert.assertQuantities(model, quantityHelper, TypeEnumeration.SPECIMEN_QUANTITY, true);
  }
Example #2
0
  /** Test the controller completeEditModel method. */
  @Test
  public void testCompleteEditModel() {
    SoftwareController controller = new SoftwareController();
    GenericServiceMockup<Type> typeService = new GenericServiceMockup<Type>();
    controller.setTypeService(typeService);

    ModelAndView model = new ModelAndView();
    ModelAndView result = controller.completeEditModel(model, Locale.US);
    assertEquals("Wrong model returned", model, result);

    CRUDAssert.assertTypes(typeService, TypeEnumeration.SOFTWARE, "types", result);
    CRUDAssert.assertEnumerationCollection(result, "softwareStatuses", SoftwareStatus.class);
  }
  /** Test the controller completeEditModel method. */
  @Test
  public void testCompleteEditModel() {
    ChemicalCompoundController controller = new ChemicalCompoundController();
    GenericServiceMockup<Container> containerService = new GenericServiceMockup<Container>();
    controller.setContainerService(containerService);
    GenericServiceMockup<Nanomaterial> specimenService = new GenericServiceMockup<Nanomaterial>();
    controller.setSpecimenService(specimenService);

    ModelAndView model = new ModelAndView();
    ChemicalCompoundForm form = new ChemicalCompoundForm();
    model.addObject("form", form);
    ModelAndView result = controller.completeEditModel(model, Locale.US);
    assertEquals("Wrong model returned", model, result);
    CRUDAssert.assertFindAll(containerService, Container.class, "name", "containers", result);
    CRUDAssert.assertFindAll(specimenService, Nanomaterial.class, "name", "nanomaterials", result);
  }
Example #4
0
 /** Test the controller constructor. */
 @Test
 public void testConstructor() {
   SoftwareController controller = new SoftwareController();
   CRUDAssert.assertControllerConstructor(
       controller,
       SoftwareController.URL_PREFIX,
       "administration.software.",
       "name",
       Software.class,
       SoftwareForm.class,
       CRUDTableDecorator.class);
 }
 /** Test the controller constructor. */
 @Test
 public void testConstructor() {
   NanomaterialController controller = new NanomaterialController();
   CRUDAssert.assertControllerConstructor(
       controller,
       NanomaterialController.URL_PREFIX,
       "inventory.nanomaterial.",
       "name",
       Nanomaterial.class,
       NanomaterialForm.class,
       CRUDTableDecorator.class);
 }
 /** Test the controller constructor. */
 @Test
 public void testConstructor() {
   ChemicalCompoundController controller = new ChemicalCompoundController();
   CRUDAssert.assertControllerConstructor(
       controller,
       ChemicalCompoundController.URL_PREFIX,
       "inventory.chemicalcompound.",
       "name",
       ChemicalCompound.class,
       ChemicalCompoundForm.class,
       CRUDTableDecorator.class);
 }
 /** Test the controller completeDetailsModel method. */
 @Test
 public void testCompleteDetailsModel() {
   NanomaterialController controller = new NanomaterialController();
   QuantityHelperMockup quantityHelper = new QuantityHelperMockup();
   controller.setQuantityHelper(quantityHelper);
   ModelAndView model = new ModelAndView();
   NanomaterialForm form = new NanomaterialForm();
   form.setEntity(new Nanomaterial());
   model.addObject("form", form);
   ModelAndView result = controller.completeDetailsModel(model, Locale.US);
   assertEquals("Wrong model returned", model, result);
   CRUDAssert.assertQuantities(model, quantityHelper, TypeEnumeration.SPECIMEN_QUANTITY, false);
 }