package com.j256.ormlite.stmt.mapped;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import java.sql.SQLException;
import java.util.ArrayList;
import org.junit.Test;
import com.j256.ormlite.db.BaseDatabaseType;
import com.j256.ormlite.db.DatabaseType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.support.DatabaseConnection;
import com.j256.ormlite.table.TableInfo;
public class MappedDeleteCollectionTest {
private final DatabaseType databaseType = new StubDatabaseType();
@Test(expected = SQLException.class)
public void testNoIdBuildDelete() throws Exception {
DatabaseConnection databaseConnection = createMock(DatabaseConnection.class);
ConnectionSource connectionSource = createMock(ConnectionSource.class);
expect(connectionSource.getDatabaseType()).andReturn(databaseType).anyTimes();
replay(connectionSource);
MappedDeleteCollection.deleteObjects(databaseType,
new TableInfo<NoId, Void>(connectionSource, null, NoId.class), databaseConnection,
new ArrayList<NoId>());
}
protected static class NoId {
@DatabaseField
String stuff;
}
private static class StubDatabaseType extends BaseDatabaseType {
@Override
public String getDriverClassName() {
return "foo.bar.baz";
}
@Override
public String getDatabaseName() {
return "fake";
}
public boolean isDatabaseUrlThisType(String url, String dbTypePart) {
return false;
}
}
}