import com.izouma.awesomeadmin.model.*; import com.izouma.awesomeadmin.service.*; import com.izouma.awesomeadmin.service.impl.MatchInfoServiceImpl; import com.izouma.awesomeadmin.util.RandomDataUtil; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.GenericXmlContextLoader; import org.springframework.transaction.annotation.Transactional; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.List; @RunWith(value = SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:/spring/applicationContext.xml"}, loader = GenericXmlContextLoader.class) @Transactional public class MatchTest { @Autowired UserInfoService userInfoService; @Autowired ApplyInfoService applyInfoService; @Autowired MatchInfoServiceImpl matchInfoService; @Autowired MatchDataService matchDataService; @Autowired MatchStageService matchStageService; @Autowired OSSFileService ossFileService; @Test public void createMatch() { int matchId = 448; MatchInfo matchInfo = matchInfoService.getMatchInfoById(String.valueOf(matchId)); List userInfoList = RandomDataUtil.generateRandomDataNoRepeat(userInfoService.getUserInfoList(new UserInfo()), matchInfo.getStageInfo().get(0).getTotalNum()); for (UserInfo userInfo : userInfoList) { ApplyInfo applyInfo = new ApplyInfo(); applyInfo.setMatchId(matchId); applyInfo.setUserId(userInfo.getId()); applyInfo.setGameId(userInfo.getNickname()); applyInfo.setNickname(userInfo.getUsername()); applyInfo.setAera("中国"); applyInfo.setPhone(userInfo.getPhone()); applyInfoService.apply(applyInfo); } } @Test @Transactional public void testRank() { System.out.println(matchInfoService.getRank(46)); } @Test public void uploadApk() throws FileNotFoundException { String url = ossFileService.upload(new FileInputStream(""), ""); System.out.println(url); } }