use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.
the class SubmissionPersistenceImplTest method testSearchSubmissions6.
/**
* Tests searchSubmissions method
* @throws Exception to JUnit
*/
public void testSearchSubmissions6() throws Exception {
List submissions = null;
SubmissionCriteria criteria = new SubmissionCriteria();
criteria.setLanguages(Arrays.asList(new Object[] { language1, language3 }));
submissions = persistence.searchSubmissions(criteria, 0, 100);
checkSubmissions(Arrays.asList(new Object[] { submission1, submission3, submission4 }), submissions);
criteria.setLanguages(Arrays.asList(new Object[] { language2 }));
submissions = persistence.searchSubmissions(criteria, 0, 100);
checkSubmissions(Arrays.asList(new Object[] { submission2 }), submissions);
criteria.setLanguages(Arrays.asList(new Object[] { new Language(4, "x", "x", "x", "x") }));
submissions = persistence.searchSubmissions(criteria, 0, 100);
checkSubmissions(new ArrayList(), submissions);
criteria.setLanguages(new ArrayList());
submissions = persistence.searchSubmissions(criteria, 0, 100);
checkSubmissions(new ArrayList(), submissions);
}
use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.
the class ShowLanguagesAction method execute.
/**
* ShowLanguagesAction
*
* <pre>
* </pre>
*
* @param mapping
* action mapping
* @param form
* action form
* @param request
* http servlet request
* @param response
* http servlet response
*
* @return action forward instance
*
* @throws Exception
* any errors happened
*/
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
// check admin
ActionForward forward = this.checkAdmin(mapping, context);
if (forward != null) {
return forward;
}
List<Language> languages = PersistenceManager.getInstance().getLanguagePersistence().getAllLanguages();
context.setAttribute("Languages", languages);
return this.handleSuccess(mapping, context, "success");
}
use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.
the class ContestPersistenceImplTest method testDeleteLanguage1.
/**
* Tests deleteLanguage method
* @throws Exception to JUnit
*/
public void testDeleteLanguage1() throws Exception {
List languages = persistence.getAllLanguages();
for (int i = 0; i < 3; ++i) {
Language language = (Language) languages.get(i);
long id = language.getId();
persistence.deleteLanguage(id, 10);
}
languages = persistence.getAllLanguages();
assertEquals("wrong size", 0, languages.size());
}
use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.
the class ContestPersistenceImplTest method testGetAllLanguages.
/**
* Tests getAllLanguages method
* @throws Exception to JUnit
*/
public void testGetAllLanguages() throws Exception {
List languages = persistence.getAllLanguages();
for (int i = 0; i < 3; ++i) {
Language language = (Language) languages.get(i);
long id = language.getId();
assertEquals("wrong name", "language" + id, language.getName());
assertEquals("wrong desc", "Language " + id, language.getDescription());
assertEquals("wrong options", "options" + id, language.getOptions());
assertEquals("wrong compiler", "compiler" + id, language.getCompiler());
}
}
use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.
the class ContestPersistenceImplTest method testCreateLanguage.
/**
* Tests createLanguage method
* @throws Exception to JUnit
*/
public void testCreateLanguage() throws Exception {
persistence.createLanguage(new Language(4, "language4", "Language 4", "compiler4", "options4"), 10);
List languages = persistence.getAllLanguages();
for (int i = 0; i < 4; ++i) {
Language language = (Language) languages.get(i);
long id = language.getId();
assertEquals("wrong name", "language" + id, language.getName());
assertEquals("wrong desc", "Language " + id, language.getDescription());
assertEquals("wrong options", "options" + id, language.getOptions());
assertEquals("wrong compiler", "compiler" + id, language.getCompiler());
}
}
Aggregations