Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createTenantThrowsAuthorizationException()
        public virtual void createTenantThrowsAuthorizationException()
        {
            Tenant newTenant = MockProvider.createMockTenant();

            string message = "exception expected";

            when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenThrow(new AuthorizationException(message));

            given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().post(TENANT_CREATE_URL);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failToUpdateTenantForReadOnlyService()
        public virtual void failToUpdateTenantForReadOnlyService()
        {
            Tenant updatedTenant = MockProvider.createMockTenant();

            when(identityServiceMock.ReadOnly).thenReturn(true);

            given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("Identity service implementation is read-only.")).when().put(TENANT_URL);

            verify(identityServiceMock, never()).saveTenant(mockTenant);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createExistingTenant()
        public virtual void createExistingTenant()
        {
            Tenant newTenant = MockProvider.createMockTenant();

            when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenReturn(newTenant);

            string message = "exception expected";

            doThrow(new ProcessEngineException(message)).when(identityServiceMock).saveTenant(newTenant);

            given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(ProcessEngineException).Name)).body("message", equalTo(message)).when().post(TENANT_CREATE_URL);
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createTenant()
        public virtual void createTenant()
        {
            Tenant newTenant = MockProvider.createMockTenant();

            when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenReturn(newTenant);

            given().body(TenantDto.fromTenant(mockTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.NO_CONTENT.StatusCode).when().post(TENANT_CREATE_URL);

            verify(identityServiceMock).newTenant(MockProvider.EXAMPLE_TENANT_ID);
            verify(newTenant).Name = MockProvider.EXAMPLE_TENANT_NAME;
            verify(identityServiceMock).saveTenant(newTenant);
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updateTenantThrowsAuthorizationException()
        public virtual void updateTenantThrowsAuthorizationException()
        {
            Tenant updatedTenant = MockProvider.createMockTenant();

            when(updatedTenant.Name).thenReturn("updatedName");

            string message = "exception expected";

            doThrow(new AuthorizationException(message)).when(identityServiceMock).saveTenant(any(typeof(Tenant)));

            given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().put(TENANT_URL);
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updateNonExistingTenant()
        public virtual void updateNonExistingTenant()
        {
            Tenant updatedTenant = MockProvider.createMockTenant();

            when(updatedTenant.Name).thenReturn("updatedName");

            when(mockQuery.singleResult()).thenReturn(null);

            given().pathParam("id", "aNonExistingTenant").body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.NOT_FOUND.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("Tenant with id aNonExistingTenant does not exist")).when().put(TENANT_URL);

            verify(identityServiceMock, never()).saveTenant(any(typeof(Tenant)));
        }
Example #7
0
        public virtual TenantDto getTenant(UriInfo context)
        {
            Tenant tenant = findTenantObject();

            if (tenant == null)
            {
                throw new InvalidRequestException(Status.NOT_FOUND, "Tenant with id " + resourceId + " does not exist");
            }

            TenantDto dto = TenantDto.fromTenant(tenant);

            return(dto);
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updateTenant()
        public virtual void updateTenant()
        {
            Tenant updatedTenant = MockProvider.createMockTenant();

            when(updatedTenant.Name).thenReturn("updatedName");

            given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.NO_CONTENT.StatusCode).when().put(TENANT_URL);

            // tenant was updated
            verify(mockTenant).Name = updatedTenant.Name;

            // and then saved
            verify(identityServiceMock).saveTenant(mockTenant);
        }
Example #9
0
        public virtual void updateTenant(TenantDto tenantDto)
        {
            ensureNotReadOnly();

            Tenant tenant = findTenantObject();

            if (tenant == null)
            {
                throw new InvalidRequestException(Status.NOT_FOUND, "Tenant with id " + resourceId + " does not exist");
            }

            tenantDto.update(tenant);

            identityService.saveTenant(tenant);
        }