Java Assert assertFieldPositive(int fieldValue, String fieldName)

Here you can find the source of assertFieldPositive(int fieldValue, String fieldName)

Description

Throws an IllegalArgumentException if the specified field is <=0.

License

Apache License

Parameter

Parameter Description
fieldValue The object to check.
fieldName The name of the field.

Exception

Parameter Description
IllegalArgumentException an exception

Declaration

public static void assertFieldPositive(int fieldValue, String fieldName) throws IllegalArgumentException 

Method Source Code

//package com.java2s;
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *

public class Main {
    /**/*from  w w  w .  j  a  v  a  2s . co  m*/
     * Throws an {@link IllegalArgumentException} if the specified field is <code>&lt;=0</code>.
     *
     * @param fieldValue The object to check.
     * @param fieldName The name of the field.
     * @throws IllegalArgumentException
     */
    public static void assertFieldPositive(int fieldValue, String fieldName) throws IllegalArgumentException {
        if (fieldValue <= 0)
            throw new IllegalArgumentException("Field '" + fieldName + "' must be a positive integer.");
    }
}

Related

  1. assertFailed(Object expression, Object message)
  2. assertFails(Class expectedThrowable, String pattern, int... values)
  3. assertFalse(boolean test, String message)
  4. assertFalse(final boolean result, final String message)
  5. assertFalse(String string, boolean b)
  6. assertGreater(long first, long second)
  7. assertGreaterOrEqualsThan(final long value, final long limit, final String name)
  8. assertGreaterThanOrEquals(String name, double comparedTo, double number)
  9. assertHasInterface(Class interfaceClass, Class objectClass)