congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SumFunction
Code IndexAdd Tabnine to your IDE (free)

How to use
SumFunction
in
org.kie.dmn.feel.runtime.functions

Best Java code snippets using org.kie.dmn.feel.runtime.functions.SumFunction (Showing top 14 results out of 315)

origin: org.kie/kie-dmn-feel

  public FEELFnResult<BigDecimal> invoke(@ParameterName("n") Object[] list) {
    if ( list == null ) { 
      // Arrays.asList does not accept null as parameter
      return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "n", "the single value list cannot be null"));
    }
    
    return invoke( Arrays.asList( list ) );
  }
}
origin: org.kie/kie-dmn-feel

@Before
public void setUp() {
  sumFunction = new SumFunction();
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeNumberParamSupportedNumber() {
  FunctionTestUtil.assertResult(sumFunction.invoke(BigDecimal.TEN), BigDecimal.TEN);
  FunctionTestUtil.assertResult(sumFunction.invoke(10), BigDecimal.TEN);
  FunctionTestUtil.assertResult(sumFunction.invoke(-10), BigDecimal.valueOf(-10));
  FunctionTestUtil.assertResult(sumFunction.invoke(10.12), BigDecimal.valueOf(10.12));
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeListParamSupportedTypes() {
  FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, (long) 5, BigDecimal.TEN)), BigDecimal.valueOf(30.1));
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeListParamContainsUnsupportedType() {
  FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, "test", 2)), InvalidParametersEvent.class);
}
origin: org.kie/kie-dmn-feel

  @Test
  public void invokeArrayParamSupportedTypes() {
    FunctionTestUtil.assertResult(sumFunction.invoke(new Object[]{4, -1, 12.1, (long) 5, BigDecimal.TEN}), BigDecimal.valueOf(30.1));
  }
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeListParamContainsUnsupportedNumber() {
  FunctionTestUtil.assertResultError(sumFunction.invoke(Arrays.asList(10, 2, Double.NaN)), InvalidParametersEvent.class);
}
origin: org.kie/kie-dmn-feel

public FEELFnResult<BigDecimal> invoke(@ParameterName( "list" ) List list) {
  if ( list == null ) {
    return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null"));
  }
  FEELFnResult<BigDecimal> s = sum.invoke( list );
  
  Function<FEELEvent, FEELFnResult<BigDecimal>> ifLeft = (event) -> {
    return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "unable to sum the elements which is required to calculate the mean"));
  };
  
  Function<BigDecimal, FEELFnResult<BigDecimal>> ifRight = (sum) -> {
    try {
      return FEELFnResult.ofResult( sum.divide( BigDecimal.valueOf( list.size() ), MathContext.DECIMAL128 ) );
    } catch (Exception e) {
      return FEELFnResult.ofError( new InvalidParametersEvent(Severity.ERROR, "unable to perform division to calculate the mean", e) );
    }
  };
  
  return s.cata(ifLeft, ifRight);
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeNumberParamUnsupportedNumber() {
  FunctionTestUtil.assertResultError(sumFunction.invoke(Double.NaN), InvalidParametersEvent.class);
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeArrayParam() {
  FunctionTestUtil.assertResultError(sumFunction.invoke((Object[]) null), InvalidParametersEvent.class);
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeArrayParamContainsUnsupportedType() {
  FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, "test", 2}), InvalidParametersEvent.class);
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeNumberParamNull() {
  FunctionTestUtil.assertResultError(sumFunction.invoke((Number) null), InvalidParametersEvent.class);
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeListParam() {
  FunctionTestUtil.assertResultError(sumFunction.invoke((List) null), InvalidParametersEvent.class);
}
origin: org.kie/kie-dmn-feel

@Test
public void invokeArrayParamContainsUnsupportedNumber() {
  FunctionTestUtil.assertResultError(sumFunction.invoke(new Object[]{10, 2, Double.NaN}), InvalidParametersEvent.class);
}
org.kie.dmn.feel.runtime.functionsSumFunction

Most used methods

  • invoke
  • <init>

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • onCreateOptionsMenu (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Table (org.hibernate.mapping)
    A relational table
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now