@RunWith(SpringRunner.class)
@SpringBootTest
public class OrderDetailRepositoryTest {
@Autowired
private OrderDetailRepository repository;
@Test
public void saveTest() {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setDetailId("1234567810");
orderDetail.setOrderId("11111112");
orderDetail.setProductIcon("http://xxxx.jpg");
orderDetail.setProductId("11111112");
orderDetail.setProductName("皮蛋粥");
orderDetail.setProductPrice(new BigDecimal(2.2));
orderDetail.setProductQuantity(3);
OrderDetail result = repository.save(orderDetail);
Assert.assertNotNull(result);
}
@Test
public void findByOrderId() throws Exception {
List<OrderDetail> orderDetailList = repository.findByOrderId("11111111");
Assert.assertNotEquals(0, orderDetailList.size());
}
}
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
//@Data
public class LoggerTest {
@Test
public void test1() {
String name = "imooc";
String password = "123456";
log.debug("debug...");
log.info("name: " + name + " ,password: " + password);
log.info("name: {}, password: {}", name, password);
log.error("error...");
log.warn("warn...");
}
}
@RunWith(SpringRunner.class)
@SpringBootTest
public class ProductCategoryRepositoryTest {
@Autowired
private ProductCategoryRepository repository;
@Test
public void findOneTest() {
ProductCategory productCategory = repository.findOne(1);
System.out.println(productCategory.toString());
}
@Test
@Transactional
public void saveTest() {
ProductCategory productCategory = new ProductCategory("男生最爱", 4);
ProductCategory result = repository.save(productCategory);
Assert.assertNotNull(result);
// Assert.assertNotEquals(null, result);
}
@Test
public void findByCategoryTypeInTest() {
List<Integer> list = Arrays.asList(2,3,4);
List<ProductCategory> result = repository.findByCategoryTypeIn(list);
Assert.assertNotEquals(0, result.size());
}
@Test
public void updateTest() {
// ProductCategory productCategory = repository.findOne(4);
// productCategory.setCategoryName("男生最爱1");
ProductCategory productCategory = new ProductCategory("男生最爱", 4);
ProductCategory result = repository.save(productCategory);
Assert.assertEquals(productCategory, result);
}
}
项目部署: 本项目通过maven打jar包,通过命令java -jar运行,暂时只能通过局域网访问