Class SQLInserts

    • Constructor Detail

      • SQLInserts

        protected SQLInserts()
      • SQLInserts

        public SQLInserts​(MockNeat mockNeat)
    • Method Detail

      • sqlInserts

        public static SQLInserts sqlInserts()

        Returns a SQLInserts object that can be used to generate SQL Inserts

        Returns:
        A new SQLInserts object
      • tableName

        public SQLInserts tableName​(java.lang.String tableName)

        Sets the table name for which we are generating the SQLInserts.

        If this is not called, the default table name "some_table" will be used for the INSERTs.

        Parameters:
        tableName - The table name
        Returns:
        The same SQLInserts object
      • column

        public SQLInserts column​(java.lang.String column,
                                 MockUnit<?> mockUnit)

        Associates a column of the SQL table with a corresponding MockUnit<T>

        Parameters:
        column - The column of the table
        mockUnit - The MockUnit<T> used to generate values for the column. The result is automatically transformed to String.
        Returns:
        The same SQLInserts object.
      • column

        public SQLInserts column​(java.lang.String column,
                                 MockUnit<?> mockUnit,
                                 java.util.function.Function<java.lang.String,​java.lang.String> sqlFormatter)

        Associates a column of the SQL table with a corresponding MockUnit<T>.

        Before the value is generated from the MockUnit<T> the @param sqlParameter function is applied to the values. This is useful when for example Strings have to be escaped for a given SQL dialect.

        Parameters:
        column - The column of the table
        mockUnit - The MockUnit<T> used to generate values for the column. The result is automatically transformed to String.
        sqlFormatter - The Function<String, String> for formatting the generated value
        Returns:
        The same SQLInserts instance.
      • column

        public SQLInserts column​(java.lang.String column,
                                 java.lang.String str)

        Associates a column of the SQL table with a constant value.

        Parameters:
        column - The column of the SQLTable
        str - The constant String value.
        Returns:
        The same object
      • column

        public SQLInserts column​(java.lang.String column,
                                 java.lang.String str,
                                 java.util.function.Function<java.lang.String,​java.lang.String> sqlFormatter)

        Associates a column of the SQL table with a constant value.

        Before the value is generated from the MockUnit<T> the @param sqlParameter function is applied to the values. This is useful when for example Strings have to be escaped for a given SQL dialect.

        Parameters:
        column - The column of the SQLTable
        str - The constant String value.
        sqlFormatter - The Function<String, String> for formatting the constant value
        Returns:
        The same SQLInserts object.
      • supplier

        public java.util.function.Supplier<SQLInsert> supplier()
        Description copied from interface: MockUnit
        This is the sole abstract method of the interface. Needs to be implemented every-time a MockUnit is implemented.
        Specified by:
        supplier in interface MockUnit<SQLInsert>
        Returns:
        A Supplier<T>.
      • table

        public MockUnit<SQLTable> table​(int numRows)

        Creates a MockUnit<SQLTable>, each table having a fixed number of rows

        Parameters:
        numRows - The number of rows of the table.
        Returns:
        The same SQLInserts object.