Exemple #1
0
        public void Test_0023_Save_update_add_remove_server_error_partial()
        {
            this.LogIn();

            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/group1234"));

            KiiUser user = KiiUser.CreateByUri(new Uri("kiicloud://users/user1234"));

            group.RemoveUser(user);

            user = KiiUser.CreateByUri(new Uri("kiicloud://users/user5678"));
            group.AddUser(user);

            // set Response
            client.RequestUrl.Clear();
            this.SetStandardSaveResponse();
            client.AddResponse(new CloudException(400, "{ \"errorCode\" : \"INVALID_INPUT_DATA\", \"message\" : \"There are validation errors\", \"suppressed\" : [ ]}"));

            bool      done           = false;
            KiiGroup  savedGroup     = null;
            Exception savedException = null;

            group.Save((KiiGroup retGroup, Exception retExp) =>
            {
                done           = true;
                savedGroup     = retGroup;
                savedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(savedException);
            Assert.IsTrue(savedException is GroupOperationException);
            Assert.IsNotNull(savedGroup);
            Assert.AreEqual("group1234", savedGroup.ID);

            GroupOperationException groupExp = (GroupOperationException)savedException;

            Assert.AreEqual(0, groupExp.AddFailedUsers.Count);
            Assert.AreEqual(1, groupExp.RemoveFailedUsers.Count);
        }
Exemple #2
0
        /// <summary>
        /// Throws the exception.
        /// </summary>
        /// <param name="ex">Ex.</param>
        public static void ThrowException(GroupOperationException ex)
        {
/*
 *          Throwable exp =  e.getCause();
 *          if (exp instanceof BadRequestException)
 *              throw (BadRequestException) exp;
 *          if (exp instanceof ConflictException)
 *              throw (ConflictException) exp;
 *          if (exp instanceof ForbiddenException)
 *              throw (ForbiddenException) exp;
 *          if (exp instanceof NotFoundException)
 *              throw (NotFoundException) exp;
 *          if (exp instanceof UnauthorizedException)
 *              throw (UnauthorizedException) exp;
 *          if (exp instanceof UndefinedException)
 *              throw (UndefinedException) exp;
 *          if (exp instanceof IOException)
 *              throw (IOException) exp;
 *          throw new SystemException(
 *                  SystemException.Reason.__UNKNOWN__.toString(), e,
 *                  SystemException.Reason.__UNKNOWN__);
 */
        }