Package jp.co.nskint.uq.pd.signage.model

Examples of jp.co.nskint.uq.pd.signage.model.User


    @ActionPath("{uid}/edit")
    public Navigation edit(@Var("uid") String uid) {
        putEnteringLog();
        try {
            if (checkAdmin()) {
                User user = getService().get(uid);
                if (user != null && user instanceof Administrator) {
                    request.setAttribute("uid", user.getUid().getName());
                    request.setAttribute("name", user.getName());
                    request.setAttribute("mail", user.getMail());
                    request.setAttribute(
                        "title",
                        ApplicationMessage.get("title.admin.edit"));
                    return forward("/user/edit.jsp");
                } else {
View Full Code Here


    public Navigation update(@Var("uid") String uid,
            @RequestParam("name") String name, @RequestParam("mail") String mail) {
        putEnteringLog();
        try {
            if (checkAdmin()) {
                User tmp = getService().get(uid);
                if (tmp != null && tmp instanceof Administrator) {
                    Validators v = new Validators(request);
                    v.add("name", v.required());
                    v.add("mail", v.required(), v.regexp(VALID_PAT_MAILADDR));
                    if (v.validate()) {
View Full Code Here

    public void menu_error() throws Exception {

        // ログインユーザが不正なユーザである場合(UserオブジェクトそのままのユーザはDB二登録されない)
        tester.request.getSession(true).setAttribute(
            FrontPage.SESS_KEY_LOGIN_USER,
            new User());
        tester.start("/menu");
        assertThat(tester.getPage(), is(instanceOf(FrontPage.class)));
        assertThat(tester.getActionMethodName(), is("menu"));
        assertThat(tester.isRedirect(), is(false));
        assertThat(tester.getDestinationPath(), is("/error.jsp"));
View Full Code Here

            tester.getErrors().get("page"),
            is(getMessage("error.authority")));

        tester.request.getSession(true).setAttribute(
            EditorPage.SESS_KEY_LOGIN_USER,
            new User());
        tester.start("/editor/regist");
        assertThat(tester.getPage(), is(instanceOf(EditorPage.class)));
        assertThat(tester.getActionMethodName(), is("regist"));
        assertThat(tester.isRedirect(), is(false));
        assertThat(tester.getDestinationPath(), is("/error.jsp"));
View Full Code Here

            tester.getErrors().get("page"),
            is(getMessage("error.authority")));

        tester.request.getSession(true).setAttribute(
            EditorPage.SESS_KEY_LOGIN_USER,
            new User());
        tester.start("/editor/" + UID + "/edit");
        assertThat(tester.getPage(), is(instanceOf(EditorPage.class)));
        assertThat(tester.getActionMethodName(), is("edit"));
        assertThat(tester.isRedirect(), is(false));
        assertThat(tester.getDestinationPath(), is("/error.jsp"));
View Full Code Here

    @Test
    public void put() throws Exception {
        final String uid = UID;
        final String name = "Test User";
        final String mail = "testuser@mail.com";
        User user = service.put(uid, name, mail, manager);
        assertThat(user, is(notNullValue()));
        assertThat(user, instanceOf(Editor.class));
        assertThat(user.getName(), is(name));
        assertThat(user.getMail().getEmail(), is(mail));

        assertNotNull(user.getInitialKey());
        assertThat(user.getInitialKey(), not(""));

        Editor stored = Datastore.get(Editor.class, user.getUid());
        assertThat(stored, instanceOf(Editor.class));
        assertThat(stored.getName(), is(name));
        assertThat(stored.getMail().getEmail(), is(mail));
        assertThat(stored.getRegisteredDate(), is(stored.getUpdatedDate()));

        // パスワードを保存する
        service.savePassword(uid, "password");

        final String name2 = "Test User2";
        final String mail2 = "testuser2@mail.com";
        user = service.put(uid, name2, mail2, manager);
        assertThat(user, is(notNullValue()));
        assertThat(user, instanceOf(Editor.class));
        assertThat(user.getName(), is(name2));
        assertThat(user.getMail().getEmail(), is(mail2));

        assertThat(user.getInitialKey(), is(""));

        stored = Datastore.get(Editor.class, user.getUid());
        assertThat(stored, instanceOf(Editor.class));
        assertThat(stored.getName(), is(name2));
        assertThat(stored.getMail().getEmail(), is(mail2));
        assertTrue(stored.getRegisteredDate().before(stored.getUpdatedDate()));
    }
View Full Code Here

    public void put2() throws Exception {
        final String uid = UID;
        final String name = "Test User";
        final String mail = "testuser@mail.com";
        Transaction tx = Datastore.beginTransaction();
        User user = service.put(tx, uid, name, mail, manager);
        assertThat(user, is(notNullValue()));
        assertThat(user, instanceOf(Editor.class));
        assertThat(user.getName(), is(name));
        assertThat(user.getMail().getEmail(), is(mail));

        assertNotNull(user.getInitialKey());
        assertThat(user.getInitialKey(), not(""));

        Editor stored = Datastore.getOrNull(Editor.class, user.getUid());
        assertThat(stored, is(nullValue()));

        tx.commit();
        stored = Datastore.getOrNull(Editor.class, user.getUid());
        assertThat(stored, instanceOf(Editor.class));
        assertThat(stored.getName(), is(name));
        assertThat(stored.getMail().getEmail(), is(mail));
        assertThat(stored.getRegisteredDate(), is(stored.getUpdatedDate()));
View Full Code Here

    @Test
    public void put() throws Exception {
        final String uid = UID;
        final String name = "Test User";
        final String mail = "testuser@mail.com";
        User user = service.put(uid, name, mail);
        assertThat(user, is(notNullValue()));
        assertThat(user, instanceOf(Administrator.class));
        assertThat(user.getName(), is(name));
        assertThat(user.getMail().getEmail(), is(mail));

        assertNotNull(user.getInitialKey());
        assertThat(user.getInitialKey(), not(""));

        Administrator stored = Datastore.get(Administrator.class, user.getUid());
        assertThat(stored, instanceOf(Administrator.class));
        assertThat(stored.getName(), is(name));
        assertThat(stored.getMail().getEmail(), is(mail));
        assertThat(stored.getRegisteredDate(), is(stored.getUpdatedDate()));

        // パスワードを保存する
        service.savePassword(uid, "password");

        final String name2 = "Test User2";
        final String mail2 = "testuser2@mail.com";
        user = service.put(uid, name2, mail2);
        assertThat(user, is(notNullValue()));
        assertThat(user, instanceOf(Administrator.class));
        assertThat(user.getName(), is(name2));
        assertThat(user.getMail().getEmail(), is(mail2));

        assertThat(user.getInitialKey(), is(""));

        stored = Datastore.get(Administrator.class, user.getUid());
        assertThat(stored, instanceOf(Administrator.class));
        assertThat(stored.getName(), is(name2));
        assertThat(stored.getMail().getEmail(), is(mail2));
        assertTrue(stored.getRegisteredDate().before(stored.getUpdatedDate()));
    }
View Full Code Here

    public void put2() throws Exception {
        final String uid = UID;
        final String name = "Test User";
        final String mail = "testuser@mail.com";
        Transaction tx = Datastore.beginTransaction();
        User user = service.put(tx, uid, name, mail);
        assertThat(user, is(notNullValue()));
        assertThat(user, instanceOf(Administrator.class));
        assertThat(user.getName(), is(name));
        assertThat(user.getMail().getEmail(), is(mail));

        assertNotNull(user.getInitialKey());
        assertThat(user.getInitialKey(), not(""));

        Administrator stored = Datastore.getOrNull(Administrator.class, user.getUid());
        assertThat(stored, is(nullValue()));

        tx.commit();
        stored = Datastore.getOrNull(Administrator.class, user.getUid());
        assertThat(stored, instanceOf(Administrator.class));
        assertThat(stored.getName(), is(name));
        assertThat(stored.getMail().getEmail(), is(mail));
        assertThat(stored.getRegisteredDate(), is(stored.getUpdatedDate()));
View Full Code Here

    @Test
    public void delete() throws Exception {
        final String uid = UID;
        final String name = "Test User";
        final String mail = "testuser@mail.com";
        User user = service.put(uid, name, mail);

        Administrator stored = Datastore.getOrNull(Administrator.class, user.getUid());
        assertThat(stored, is(notNullValue()));

        // 削除
        service.delete(UID);

        stored = Datastore.getOrNull(Administrator.class, user.getUid());
        assertThat(stored, is(nullValue()));

    }
View Full Code Here

TOP

Related Classes of jp.co.nskint.uq.pd.signage.model.User

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.