Java tutorial
/** * Copyright 2016 REPLACE ME OWNER (REPLACE ME YEAR) * * 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 org.homiefund.test.dao; import lombok.extern.log4j.Log4j2; import org.homiefund.api.dao.DebtPreviewDAO; import org.homiefund.api.dao.InvitationDAO; import org.homiefund.api.dao.domain.DebtPreview; import org.homiefund.test.config.AbstractDAOTest; import org.homiefund.test.config.DAOTest; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.Collection; /** * Created by Dominik Szalai - emptulik at gmail.com on 26.9.2016. */ @DAOTest @Log4j2 @RunWith(SpringJUnit4ClassRunner.class) public class DebtPreviewDAOTest extends AbstractDAOTest { @Autowired private DebtPreviewDAO debtPreviewDAO; @BeforeClass public static void setUp() { checkMethods(InvitationDAOTest.class, InvitationDAO.class); } @Test(expected = UnsupportedOperationException.class) public void create() { debtPreviewDAO.create(null); } @Test(expected = UnsupportedOperationException.class) public void update() { debtPreviewDAO.update(null); } @Test(expected = UnsupportedOperationException.class) public void delete() { debtPreviewDAO.delete(null); } @Test(expected = UnsupportedOperationException.class) public void getById() { debtPreviewDAO.getById(null); } @Test(expected = UnsupportedOperationException.class) public void getAll() { debtPreviewDAO.getAll(); } @Test public void getTransactionsForPreview() { Collection<DebtPreview> list = debtPreviewDAO.getTransactionsForPreview(homeDAO.getById(1L)); Assert.assertEquals(18, list.size()); list.forEach(dp -> { Assert.assertEquals(Long.valueOf(1L), dp.getHome()); }); } }