Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright 2012-2015 the original author or authors.
*/
package org.assertj.db.api;
import org.assertj.db.api.assertions.*;
import org.assertj.db.api.assertions.impl.*;
import org.assertj.db.api.origin.OriginWithColumnsAndRowsFromChange;
import org.assertj.db.exception.AssertJDBException;
import org.assertj.db.type.Change;
import org.assertj.db.type.ChangeType;
import org.assertj.db.type.DataType;
import org.assertj.db.type.Row;
import org.assertj.db.util.Changes;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Assertion methods for a {@link Change}.
*
* @author Régis Pouiller
*/
public class ChangeAssert
extends AbstractAssertWithOriginWithChanges
implements OriginWithColumnsAndRowsFromChange,
AssertOnDataType,
AssertOnPrimaryKey,
AssertOnChangeType,
AssertOnModifiedColumns,
AssertOnNumberOfColumns {
/**
* The actual change on which the assertion is.
*/
private final Change change;
/**
* The assertion on the row at start point.
*/
private ChangeRowAssert changeRowAssertAtStartPoint;
/**
* The assertion on the row at end point.
*/
private ChangeRowAssert changeRowAssertAtEndPoint;
/**
* Index of the next value to get.
*/
private int indexNextColumn;
/**
* Map the columns assert with their index in key (contains the columns assert already generated).
*/
private final Map columnsAssertMap = new HashMap<>();
/**
* Constructor.
*
* @param origin The assertion of {@link org.assertj.db.api.origin.Origin}.
* @param change The {@link Change} on which are the assertions.
*/
ChangeAssert(ChangesAssert origin, Change change) {
super(ChangeAssert.class, origin);
this.change = change;
}
/** {@inheritDoc} */
@Override
public ChangeRowAssert rowAtStartPoint() {
if (changeRowAssertAtStartPoint == null) {
String string = "Row at start point of " + info.descriptionText();
changeRowAssertAtStartPoint = new ChangeRowAssert(this, change.getRowAtStartPoint()).as(string);
}
return changeRowAssertAtStartPoint;
}
/** {@inheritDoc} */
@Override
public ChangeRowAssert rowAtEndPoint() {
if (changeRowAssertAtEndPoint == null) {
String string = "Row at end point of " + info.descriptionText();
changeRowAssertAtEndPoint = new ChangeRowAssert(this, change.getRowAtEndPoint()).as(string);
}
return changeRowAssertAtEndPoint;
}
/**
* Gets an instance of value assert corresponding to the index. If this instance is already instanced, the method
* returns it from the cache.
*
* @param index Index of the value on which is the instance of value assert.
* @return The value assert implementation.
* @throws org.assertj.db.exception.AssertJDBException If the {@code index} is out of the bounds.
*/
private ChangeColumnAssert getChangeColumnAssertInstance(int index) {
if (columnsAssertMap.containsKey(index)) {
ChangeColumnAssert changeColumnAssert = columnsAssertMap.get(index);
indexNextColumn = index + 1;
return changeColumnAssert;
}
int size = change.getColumnsNameList().size();
if (index < 0 || index >= size) {
throw new AssertJDBException("Index %s out of the limits [0, %s[", index, size);
}
Row rowAtStartPoint = change.getRowAtStartPoint();
Row rowAtEndPoint = change.getRowAtEndPoint();
Object valueAtStartPoint = null;
Object valueAtEndPoint = null;
if (rowAtStartPoint != null) {
List