use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method replaceCategory.
@Test
public void replaceCategory() throws URISyntaxException, MCRException, SAXParseException, IOException {
loadWorldClassification2();
addWorldClassification();
DAO.replaceCategory(category2);
startNewTransaction();
MCRCategoryImpl rootNode = getRootCategoryFromSession();
assertEquals("Category count does not match.", countNodes(category2), countNodes(rootNode));
assertEquals("Label count does not match.", category2.getChildren().get(0).getLabels().size(), rootNode.getChildren().get(0).getLabels().size());
checkLeftRightLevelValue(rootNode, 0, 0);
final URI germanURI = new URI("http://www.deutschland.de");
final MCRCategory germany = rootNode.getChildren().get(0).getChildren().get(0);
assertEquals("URI was not updated", germanURI, germany.getURI());
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method removeLabel.
@Test
public void removeLabel() {
addWorldClassification();
final MCRCategory labelNode = category.getChildren().get(0);
int labelCount = labelNode.getLabels().size();
DAO.removeLabel(labelNode.getId(), "en");
startNewTransaction();
final MCRCategory labelNodeNew = getRootCategoryFromSession().getChildren().get(0);
assertEquals("Label count did not match.", labelCount - 1, labelNodeNew.getLabels().size());
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method replaceSameCategory.
@Test
public void replaceSameCategory() throws Exception {
loadWorldClassification2();
addWorldClassification();
MCRCategory oldCategory = DAO.getCategory(new MCRCategoryID("World", "Europe"), -1);
DAO.replaceCategory(oldCategory);
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method setLabel.
@Test
public void setLabel() {
addWorldClassification();
startNewTransaction();
// test add
int count = category.getLabels().size();
final String lang = "ju";
final String text = "JUnit-Test";
DAO.setLabel(category.getId(), new MCRLabel(lang, text, "Added by JUnit"));
startNewTransaction();
MCRCategory rootNode = getRootCategoryFromSession();
assertEquals("Label count does not match.", count + 1, rootNode.getLabels().size());
// test modify
String description = "Modified by JUnit";
DAO.setLabel(category.getId(), new MCRLabel(lang, text, description));
startNewTransaction();
rootNode = getRootCategoryFromSession();
assertEquals("Label count does not match.", count + 1, rootNode.getLabels().size());
assertEquals("Label does not match.", description, rootNode.getLabel(lang).get().getDescription());
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method setLabels.
@Test
public void setLabels() {
addWorldClassification();
startNewTransaction();
MCRCategory germany = DAO.getCategory(MCRCategoryID.fromString("World:Germany"), 0);
MCRCategory france = DAO.getCategory(MCRCategoryID.fromString("World:France"), 0);
Set<MCRLabel> labels1 = new HashSet<>();
labels1.add(new MCRLabel("de", "deutschland", null));
DAO.setLabels(germany.getId(), labels1);
startNewTransaction();
Set<MCRLabel> labels2 = new HashSet<>();
labels2.add(new MCRLabel("de", "frankreich", null));
DAO.setLabels(france.getId(), labels2);
startNewTransaction();
germany = DAO.getCategory(MCRCategoryID.fromString("World:Germany"), 0);
france = DAO.getCategory(MCRCategoryID.fromString("World:France"), 0);
assertEquals(1, germany.getLabels().size());
assertEquals(1, france.getLabels().size());
assertEquals("deutschland", germany.getLabel("de").get().getText());
assertEquals("frankreich", france.getLabel("de").get().getText());
}
Aggregations