Package com.sparc.knappsack.components.entities

Examples of com.sparc.knappsack.components.entities.Organization


    }

    @Test
    public void testInvalid() {
        Domain domain = new Organization();
        domain.getUuid();

        Mockito.when(domainService.getByUUID(form.getDomainUUID())).thenReturn(null);
        Mockito.when(domainService.getDomainForRegion(form.getRegion())).thenReturn(null);
        Mockito.when(domainRequestService.doesDomainRequestExist(domain.getId(), form.getEmailAddress())).thenReturn(true);

        validator.validate(form, errors);
        assertEquals(errors.getErrorCount(), 10);

        setup();

        Mockito.when(domainService.getByUUID(form.getDomainUUID())).thenReturn(null);
        Mockito.when(domainService.getDomainForRegion(form.getRegion())).thenReturn(null);
        Mockito.when(domainRequestService.doesDomainRequestExist(domain.getId(), form.getEmailAddress())).thenReturn(true);

        validator.validate(form, errors);
        assertEquals(errors.getErrorCount(), 10);
    }
View Full Code Here


        assertEquals(errors.getErrorCount(), 10);
    }

    @Test
    public void testRequestExists() {
        Domain domain = new Organization();
        domain.setId(1L);
        domain.getUuid();

        form.setDomainUUID(domain.getUuid());
        form.setAddress("testAddress");
        form.setCompanyName("testCompany");
        form.setEmailAddress("test@test.com");
        form.setFirstName("firstName");
        form.setLastName("lastName");
        form.setRegion(1L);
        form.setDeviceType(DeviceType.IPAD_1);
        form.setPhoneNumber("1231231234");
        form.getLanguages().add(Language.ENGLISH);

        Mockito.when(domainService.getByUUID(form.getDomainUUID())).thenReturn(domain);
        Mockito.when(domainService.getDomainForRegion(form.getRegion())).thenReturn(domain);
        Mockito.when(domainRequestService.doesDomainRequestExist(domain.getId(), form.getEmailAddress())).thenReturn(true);

        validator.validate(form, errors);
        assertEquals(errors.getErrorCount(), 1);
        assertEquals(errors.getGlobalErrorCount(), 1);
    }
View Full Code Here

        organizationForm.setStorageConfigurationId(1L);
        organizationForm.setStoragePrefix("prefix");
//        organizationForm.setAdminEmail("valid@valid.com");
        organizationForm.setId(1L);

        Organization organization = new Organization();
        organization.setId(1L);

        OrgStorageConfig orgStorageConfig = new OrgStorageConfig();
        orgStorageConfig.setOrganization(organization);

        Mockito.when(organizationService.getByName(organizationForm.getName())).thenReturn(organization);
View Full Code Here

        //Adding new organization
        organizationForm.setName("name");
        organizationForm.setStoragePrefix("prefix");
        organizationForm.setStorageConfigurationId(1L);

        Organization organization = new Organization();
        organization.setId(1L);

        Mockito.when(organizationService.getByName(organizationForm.getName())).thenReturn(organization);
        Mockito.when(orgStorageConfigService.getByPrefix(Matchers.anyString())).thenReturn(null);

        validator.validate(organizationForm, errors);

        assertTrue(errors.hasErrors());
        Assert.assertEquals(errors.getErrorCount(), 1);
        assertNotNull(errors.getFieldError("name"));

        setup();

        //Editing
        organizationForm.setName("name");
        organizationForm.setStoragePrefix("prefix");
        organizationForm.setStorageConfigurationId(1L);
        organizationForm.setId(2L);

        organization = new Organization();
        organization.setId(1L);

        Mockito.when(organizationService.getByName(organizationForm.getName())).thenReturn(organization);
        Mockito.when(orgStorageConfigService.getByPrefix(Matchers.anyString())).thenReturn(null);

        validator.validate(organizationForm, errors);
View Full Code Here

        organizationForm.setName("name");
        organizationForm.setStorageConfigurationId(1L);
        organizationForm.setStoragePrefix("prefix");

        OrgStorageConfig orgStorageConfig = new OrgStorageConfig();
        Organization organization = new Organization();
        organization.setId(1L);
        orgStorageConfig.setOrganization(organization);

        Mockito.when(organizationService.getByName(organizationForm.getName())).thenReturn(null);
        Mockito.when(orgStorageConfigService.getByPrefix(organizationForm.getStoragePrefix())).thenReturn(orgStorageConfig);
View Full Code Here

    @Test
    public void testValid() {
        groupForm.setName("name");

        User user = new User();
        Organization organization = new Organization();
        organization.setId(1L);
        user.setActiveOrganization(organization);

        Mockito.when(mockUserService.getUserFromSecurityContext()).thenReturn(user);
        Mockito.when(mockGroupService.get(groupForm.getName(), user.getActiveOrganization().getId())).thenReturn(null);
View Full Code Here

    @Test
    public void testGroupNameAlreadyExists() {
        groupForm.setName("name");

        User user = new User();
        Organization organization = new Organization();
        organization.setId(1L);
        user.setActiveOrganization(organization);

        Mockito.when(mockUserService.getUserFromSecurityContext()).thenReturn(user);
        Mockito.when(mockGroupService.get(groupForm.getName(), user.getActiveOrganization().getId())).thenReturn(new Group());
View Full Code Here

        assertFalse(validator.supports(String.class));
    }

    @Test
    public void testValid() {
        Domain domain = new Organization();
        domain.setId(1L);
        domain.getUuid();

        form.setDomainUUID(domain.getUuid());
        form.setAddress("testAddress");
        form.setCompanyName("testCompany");
        form.setEmailAddress("test@test.com");
        form.setFirstName("firstName");
        form.setLastName("lastName");
        form.setRegion(1L);
        form.setDeviceType(DeviceType.IPAD_1);
        form.setPhoneNumber("1231231234");
        form.getLanguages().add(Language.ENGLISH);

        Mockito.when(domainService.getByUUID(form.getDomainUUID())).thenReturn(domain);
        Mockito.when(domainService.getDomainForRegion(form.getRegion())).thenReturn(domain);
        Mockito.when(domainRequestService.doesDomainRequestExist(domain.getId(), form.getEmailAddress())).thenReturn(false);

        validator.validate(form, errors);
        assertEquals(errors.getErrorCount(), 0);

    }
View Full Code Here

    @PreAuthorize("isOrganizationAdmin(#id) or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/manager/editOrg/{id}", method = RequestMethod.GET)
    public String editOrganization(HttpServletRequest request, Model model, @PathVariable Long id)  {
        checkRequiredEntity(organizationService, id);
        Organization existingOrg = organizationService.get(id);

        if (existingOrg != null) {
            if (!model.containsAttribute("organization")) {
                OrganizationForm orgForm = new OrganizationForm();
                orgForm.setEditing(true);
                orgForm.setName(existingOrg.getName());
                orgForm.setId(existingOrg.getId());
                orgForm.setStorageConfigurationId(existingOrg.getOrgStorageConfig().getStorageConfigurations().get(0).getId());
                orgForm.setStoragePrefix(existingOrg.getOrgStorageConfig().getPrefix());

                if (existingOrg.getCustomBranding() != null) {
                    AppFile logo = existingOrg.getCustomBranding().getLogo();
                    if (logo != null) {
                        MockMultipartFile logoMultipartFile = new MockMultipartFile(logo.getName(), logo.getName(), logo.getType(), new byte[0]);
                        orgForm.setLogo(logoMultipartFile);
                    }
                    orgForm.setEmailHeader(existingOrg.getCustomBranding().getEmailHeader());
                    orgForm.setEmailFooter(existingOrg.getCustomBranding().getEmailFooter());
                    orgForm.setSubdomain(existingOrg.getCustomBranding().getSubdomain());
                }

                model.addAttribute("organization", orgForm);
            } else {
                ((OrganizationForm) model.asMap().get("organization")).setStorageConfigurationId(existingOrg.getOrgStorageConfig().getStorageConfigurations().get(0).getId());
            }
            model.addAttribute("originalName", existingOrg.getName());
            model.addAttribute("categories", existingOrg.getCategories());
            model.addAttribute("appStates", AppState.values());
//            List<ApplicationVersion> applicationVersions = applicationVersionService.getAll(existingOrg.getId());
//            model.addAttribute("applicationVersions", applicationVersions);
//            boolean hasApplicationRequests = false;
//            for (ApplicationVersion applicationVersion : applicationVersions) {
View Full Code Here

                ObjectError error = new ObjectError("organizationForm", codes, null, null);
                bindingResult.addError(error);
                return addOrganization(model);
            }

            Organization organization = organizationService.createOrganization(organizationForm);
            if (organization == null || organization.getId() == null || organization.getId() <= 0) {
                String[] codes = {"desktop.manager.organization.create.error"};
                ObjectError error = new ObjectError("organizationForm", codes, null, null);
                bindingResult.addError(error);
                return addOrganization(model);
            }
            categoryService.createDefaultCategories(organization.getId());
            orgId = organization.getId();
        }

        if (orgId == null || orgId <= 0) {
            return "redirect:/manager/viewOrgs";
        }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.components.entities.Organization

Copyright © 2018 www.massapicom. 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.