Search in sources :

Example 1 with OneFilteringOnClassEntity

use of org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity in project jersey by jersey.

the class JsonEntityFilteringClientTest method testEntityAnnotationsDefaultView.

@Test
public void testEntityAnnotationsDefaultView() throws Exception {
    final OneFilteringOnClassEntity entity = target().request().post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE, new Annotation[] { new DefaultFilteringScope() }), OneFilteringOnClassEntity.class);
    _testEmptyEntity(entity);
}
Also used : DefaultFilteringScope(org.glassfish.jersey.tests.e2e.entity.filtering.DefaultFilteringScope) Annotation(java.lang.annotation.Annotation) OneFilteringOnClassEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 2 with OneFilteringOnClassEntity

use of org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity in project jersey by jersey.

the class JsonEntityFilteringClientTest method testInvalidConfiguration.

@Test
public void testInvalidConfiguration() throws Exception {
    final ClientConfig config = new ClientConfig().property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, "invalid_value");
    configureClient(config);
    final OneFilteringOnClassEntity entity = ClientBuilder.newClient(config).target(getBaseUri()).request().post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE), OneFilteringOnClassEntity.class);
    _testEmptyEntity(entity);
}
Also used : ClientConfig(org.glassfish.jersey.client.ClientConfig) OneFilteringOnClassEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 3 with OneFilteringOnClassEntity

use of org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity in project jersey by jersey.

the class JsonEntityFilteringClientTest method testEntityAnnotationsInvalidView.

@Test
public void testEntityAnnotationsInvalidView() throws Exception {
    final OneFilteringOnClassEntity entity = target().request().post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE, new Annotation[] { CustomAnnotationLiteral.INSTANCE }), OneFilteringOnClassEntity.class);
    _testEmptyEntity(entity);
}
Also used : Annotation(java.lang.annotation.Annotation) OneFilteringOnClassEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 4 with OneFilteringOnClassEntity

use of org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity in project jersey by jersey.

the class JsonEntityFilteringOnClassTest method testOneEntityFilteringOnClassDefaultViewResponse.

@Test
public void testOneEntityFilteringOnClassDefaultViewResponse() throws Exception {
    final OneFilteringOnClassEntity entity = target("OneFilteringEntityDefaultViewResponse").request().get(OneFilteringOnClassEntity.class);
    // OneFilteringOnClassEntity
    assertThat(entity.field, is(0));
    assertThat(entity.accessorTransient, nullValue());
    assertThat(entity.getProperty(), nullValue());
    // FilteredClassEntity
    final FilteredClassEntity filtered = entity.getFiltered();
    assertThat(filtered, nullValue());
    // DefaultFilteringSubEntity
    assertThat(entity.getDefaultEntities(), nullValue());
    // OneFilteringSubEntity
    assertThat(entity.getSubEntities(), nullValue());
}
Also used : FilteredClassEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.FilteredClassEntity) OneFilteringOnClassEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 5 with OneFilteringOnClassEntity

use of org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity in project jersey by jersey.

the class JsonEntityFilteringOnClassTest method testOneEntityFilteringOnClass.

@Test
public void testOneEntityFilteringOnClass() throws Exception {
    final OneFilteringOnClassEntity entity = target("OneFilteringEntity").request().get(OneFilteringOnClassEntity.class);
    // OneFilteringOnClassEntity
    assertThat(entity.field, is(10));
    assertThat(entity.accessorTransient, is("propertyproperty"));
    assertThat(entity.getProperty(), is("property"));
    // FilteredClassEntity
    final FilteredClassEntity filtered = entity.getFiltered();
    assertThat(filtered, notNullValue());
    assertThat(filtered.field, is(0));
    assertThat(filtered.getProperty(), nullValue());
    // DefaultFilteringSubEntity
    assertThat(entity.getDefaultEntities(), notNullValue());
    assertThat(entity.getDefaultEntities().size(), is(1));
    final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.getDefaultEntities().get(0);
    assertThat(defaultFilteringSubEntity.field, is(true));
    assertThat(defaultFilteringSubEntity.getProperty(), is(20L));
    // OneFilteringSubEntity
    assertThat(entity.getSubEntities(), notNullValue());
    assertThat(entity.getSubEntities().size(), is(1));
    final OneFilteringSubEntity oneFilteringSubEntity = entity.getSubEntities().get(0);
    assertThat(oneFilteringSubEntity.field1, is(20));
    assertThat(oneFilteringSubEntity.field2, is(30));
    assertThat(oneFilteringSubEntity.getProperty1(), is("property1"));
    assertThat(oneFilteringSubEntity.getProperty2(), is("property2"));
}
Also used : FilteredClassEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.FilteredClassEntity) DefaultFilteringSubEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.DefaultFilteringSubEntity) OneFilteringSubEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringSubEntity) OneFilteringOnClassEntity(org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Aggregations

OneFilteringOnClassEntity (org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity)9 Test (org.junit.Test)8 JerseyTest (org.glassfish.jersey.test.JerseyTest)7 Annotation (java.lang.annotation.Annotation)3 ClientConfig (org.glassfish.jersey.client.ClientConfig)3 FilteredClassEntity (org.glassfish.jersey.tests.e2e.entity.filtering.domain.FilteredClassEntity)3 DefaultFilteringScope (org.glassfish.jersey.tests.e2e.entity.filtering.DefaultFilteringScope)1 DefaultFilteringSubEntity (org.glassfish.jersey.tests.e2e.entity.filtering.domain.DefaultFilteringSubEntity)1 OneFilteringSubEntity (org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringSubEntity)1