Search in sources :

Example 1 with DummyBean

use of org.jboss.weld.probe.tests.integration.deployment.beans.DummyBean in project core by weld.

the class ProbeExtensionsTest method testExtensionVisibleInProbe.

@Test
public void testExtensionVisibleInProbe() throws IOException {
    JsonObject beansInTestArchive = getPageAsJSONObject(BEANS_PATH_ALL, url);
    assertNotNull(beansInTestArchive);
    JsonArray beansArray = beansInTestArchive.getJsonArray(DATA);
    ReadContext ctx = JsonPath.parse(beansInTestArchive.toString());
    List<String> beanClasses = ctx.read("$." + DATA + "[*]." + BEAN_CLASS, List.class);
    assertBeanClassVisibleInProbe(TestExtension.class, beanClasses);
    // test extension attributes
    JsonObject extensionBeanDetail = getBeanDetail(BEANS_PATH_ALL, TestExtension.class, url);
    assertEquals(BeanType.EXTENSION.name(), extensionBeanDetail.getString(KIND));
    ctx = JsonPath.parse(extensionBeanDetail.toString());
    List<String> observedTypes = ctx.read("$." + DECLARED_OBSERVERS + "[*]." + OBSERVED_TYPE, List.class);
    assertTrue("Cannot find ProcessAnnotatedType observer method!", observedTypes.contains(ProcessAnnotatedType.class.getName() + "<DummyBean>"));
    // test bean altered by extension
    JsonObject dummyBeanDetail = getBeanDetail(BEANS_PATH_ALL, DummyBean.class, url);
    ctx = JsonPath.parse(dummyBeanDetail.toString());
    List<String> qualifiers = ctx.read("$." + QUALIFIERS + "[*]", List.class);
    assertTrue("Cannot find " + Collector.class + " qualifier on " + DummyBean.class, qualifiers.contains("@" + Collector.class.getName().concat("(value=\"\")")));
}
Also used : JsonArray(javax.json.JsonArray) ProcessAnnotatedType(javax.enterprise.inject.spi.ProcessAnnotatedType) ReadContext(com.jayway.jsonpath.ReadContext) Collector(org.jboss.weld.probe.tests.integration.deployment.annotations.Collector) JsonObject(javax.json.JsonObject) DummyBean(org.jboss.weld.probe.tests.integration.deployment.beans.DummyBean) Test(org.junit.Test)

Aggregations

ReadContext (com.jayway.jsonpath.ReadContext)1 ProcessAnnotatedType (javax.enterprise.inject.spi.ProcessAnnotatedType)1 JsonArray (javax.json.JsonArray)1 JsonObject (javax.json.JsonObject)1 Collector (org.jboss.weld.probe.tests.integration.deployment.annotations.Collector)1 DummyBean (org.jboss.weld.probe.tests.integration.deployment.beans.DummyBean)1 Test (org.junit.Test)1