Search in sources :

Example 41 with ELContext

use of javax.el.ELContext in project ART-TIME by Artezio.

the class CustomOutputLabelRendererTest method testDetermineRequireness.

@Test
public void testDetermineRequireness() throws Exception {
    TestObject testObject = new TestObject();
    ELContext elContext = createMock(ELContext.class);
    setField(renderer, "elContext", elContext);
    UIComponent component = createMock(UIComponent.class);
    ValueExpression valueExpression = createMock(ValueExpression.class);
    ValueReference valueReference = createMock(ValueReference.class);
    PowerMock.mockStatic(ValueExpressionAnalyzer.class);
    expect(component.getValueExpression("value")).andReturn(valueExpression);
    expect(ValueExpressionAnalyzer.getReference(elContext, valueExpression)).andReturn(valueReference);
    expect(valueReference.getBase()).andReturn(testObject);
    expect(valueReference.getProperty()).andReturn("attr_1");
    PowerMock.replayAll(ValueExpressionAnalyzer.class, component, valueReference);
    boolean actual = renderer.determineRequireness(component);
    PowerMock.verifyAll();
    assertFalse(actual);
}
Also used : ELContext(javax.el.ELContext) ValueExpression(javax.el.ValueExpression) UIComponent(javax.faces.component.UIComponent) ValueReference(javax.el.ValueReference) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 42 with ELContext

use of javax.el.ELContext in project ART-TIME by Artezio.

the class CustomOutputLabelRendererTest method testDetermineRequireness_ifFieldMarkNotNull.

@Test
public void testDetermineRequireness_ifFieldMarkNotNull() throws Exception {
    TestObject testObject = new TestObject();
    ELContext elContext = createMock(ELContext.class);
    setField(renderer, "elContext", elContext);
    UIComponent component = createMock(UIComponent.class);
    ValueExpression valueExpression = createMock(ValueExpression.class);
    ValueReference valueReference = createMock(ValueReference.class);
    PowerMock.mockStatic(ValueExpressionAnalyzer.class);
    expect(component.getValueExpression("value")).andReturn(valueExpression);
    expect(ValueExpressionAnalyzer.getReference(elContext, valueExpression)).andReturn(valueReference);
    expect(valueReference.getBase()).andReturn(testObject);
    expect(valueReference.getProperty()).andReturn("notNullAttr");
    PowerMock.replayAll(ValueExpressionAnalyzer.class, component, valueReference);
    boolean actual = renderer.determineRequireness(component);
    PowerMock.verifyAll();
    assertTrue(actual);
}
Also used : ELContext(javax.el.ELContext) ValueExpression(javax.el.ValueExpression) UIComponent(javax.faces.component.UIComponent) ValueReference(javax.el.ValueReference) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 43 with ELContext

use of javax.el.ELContext in project ART-TIME by Artezio.

the class CustomOutputLabelRendererTest method testDetermineRequireness_ifGetterMarkNotBlank.

@Test
public void testDetermineRequireness_ifGetterMarkNotBlank() throws Exception {
    TestObject testObject = new TestObject();
    ELContext elContext = createMock(ELContext.class);
    setField(renderer, "elContext", elContext);
    UIComponent component = createMock(UIComponent.class);
    ValueExpression valueExpression = createMock(ValueExpression.class);
    ValueReference valueReference = createMock(ValueReference.class);
    PowerMock.mockStatic(ValueExpressionAnalyzer.class);
    expect(component.getValueExpression("value")).andReturn(valueExpression);
    expect(ValueExpressionAnalyzer.getReference(elContext, valueExpression)).andReturn(valueReference);
    expect(valueReference.getBase()).andReturn(testObject);
    expect(valueReference.getProperty()).andReturn("notBlankAttr");
    PowerMock.replayAll(ValueExpressionAnalyzer.class, component, valueReference);
    boolean actual = renderer.determineRequireness(component);
    PowerMock.verifyAll();
    assertTrue(actual);
}
Also used : ELContext(javax.el.ELContext) ValueExpression(javax.el.ValueExpression) UIComponent(javax.faces.component.UIComponent) ValueReference(javax.el.ValueReference) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 44 with ELContext

use of javax.el.ELContext in project ART-TIME by Artezio.

the class CustomOutputLabelRendererTest method testDetermineRequireness_ifFieldIsNull.

@Test
public void testDetermineRequireness_ifFieldIsNull() throws Exception {
    TestObject testObject = new TestObject();
    ELContext elContext = createMock(ELContext.class);
    setField(renderer, "elContext", elContext);
    UIComponent component = createMock(UIComponent.class);
    ValueExpression valueExpression = createMock(ValueExpression.class);
    ValueReference valueReference = createMock(ValueReference.class);
    PowerMock.mockStatic(ValueExpressionAnalyzer.class);
    expect(component.getValueExpression("value")).andReturn(valueExpression);
    expect(ValueExpressionAnalyzer.getReference(elContext, valueExpression)).andReturn(valueReference);
    expect(valueReference.getBase()).andReturn(testObject);
    expect(valueReference.getProperty()).andReturn("not_existed_attr");
    PowerMock.replayAll(ValueExpressionAnalyzer.class, component, valueReference);
    boolean actual = renderer.determineRequireness(component);
    PowerMock.verifyAll();
    assertFalse(actual);
}
Also used : ELContext(javax.el.ELContext) ValueExpression(javax.el.ValueExpression) UIComponent(javax.faces.component.UIComponent) ValueReference(javax.el.ValueReference) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 45 with ELContext

use of javax.el.ELContext in project ART-TIME by Artezio.

the class CustomOutputLabelRendererTest method testDetermineRequireness_ifValueReferenceIsNull.

@Test
public void testDetermineRequireness_ifValueReferenceIsNull() throws Exception {
    ELContext elContext = createMock(ELContext.class);
    setField(renderer, "elContext", elContext);
    UIComponent component = createMock(UIComponent.class);
    ValueExpression valueExpression = createMock(ValueExpression.class);
    PowerMock.mockStatic(ValueExpressionAnalyzer.class);
    expect(component.getValueExpression("value")).andReturn(valueExpression);
    expect(ValueExpressionAnalyzer.getReference(elContext, valueExpression)).andReturn(null);
    PowerMock.replayAll(ValueExpressionAnalyzer.class, component);
    boolean actual = renderer.determineRequireness(component);
    PowerMock.verifyAll();
    assertFalse(actual);
}
Also used : ELContext(javax.el.ELContext) ValueExpression(javax.el.ValueExpression) UIComponent(javax.faces.component.UIComponent) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ELContext (javax.el.ELContext)47 ValueExpression (javax.el.ValueExpression)31 Test (org.junit.Test)29 ExpressionFactory (javax.el.ExpressionFactory)22 ELContextImpl (org.apache.jasper.el.ELContextImpl)15 ValueReference (javax.el.ValueReference)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 UIComponent (javax.faces.component.UIComponent)7 ELException (javax.el.ELException)4 ELResolver (javax.el.ELResolver)4 BeanELResolver (javax.el.BeanELResolver)3 ArrayELResolver (javax.el.ArrayELResolver)2 CompositeELResolver (javax.el.CompositeELResolver)2 FunctionMapper (javax.el.FunctionMapper)2 ListELResolver (javax.el.ListELResolver)2 MapELResolver (javax.el.MapELResolver)2 ResourceBundleELResolver (javax.el.ResourceBundleELResolver)2 VariableMapper (javax.el.VariableMapper)2 FacesContext (javax.faces.context.FacesContext)2 ExpressionFactoryImpl (de.odysseus.el.ExpressionFactoryImpl)1