/*
* Copyright 2009-2012 the original author or authors.
*
* 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.
*/
package table;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import model.Author;
import model.Book;
import org.jdal.swing.ListTableModel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
/**
* Test Table related classes
*
* @author Jose Luis Martin - (jlm@joseluismartin.info)
*/
@RunWith(BlockJUnit4ClassRunner.class)
public class TestTable {
@Test
public void testNestedProperties() {
ListTableModel tableModel = new ListTableModel();
tableModel.setModelClass(Book.class);
tableModel.setColumnNames(new String[] {"author.name"});
Author author = new Author("Name", "Surname");
Book book = new Book("Title", author);
List<Book> books = new ArrayList<Book>();
books.add(book);
tableModel.setList(books);
assertEquals("author.name", tableModel.getPropertyName(1));
assertEquals(String.class, tableModel.getColumnClass(1));
assertEquals("Name", tableModel.getValueAt(0, 1));
}
}