loadTestData(getClass().getPackage().getName(), "The Bodyguard.xml");
em.getTransaction().begin();
try {
Release release = releaseRepository.findByName("The Bodyguard (Original Soundtrack Album)").iterator().next();
ClassificationEntity classification = new ClassificationEntity();
classification.setName("Pop");
classification.setType(Classification.GENRE);
ClassificationReferenceEntity classificationReference = new ClassificationReferenceEntity();
classificationReference.setReferenceTo(SMDIdentityReferenceEntity.forEntity(release));
classificationReference.setLastUpdated(new Date());
classificationReference.setLastUpdatedBy("JUnit");
classification.addReference(classificationReference);
classification.setLastUpdated(new Date());
classification.setLastUpdatedBy("JUnit");
for (Track track : release.getTracks()) {
classificationReference = new ClassificationReferenceEntity();
classificationReference.setReferenceTo(SMDIdentityReferenceEntity.forEntity(track));
classificationReference.setLastUpdated(new Date());
classificationReference.setLastUpdatedBy("JUnit");
classification.addReference(classificationReference);
}
classificationRepository.create(classification);
Collection<ClassificationEntity> classifications = classificationRepository.findByNameAndType("Pop", Classification.GENRE);
assert classifications != null;
assert classifications.size() == 1;
classification = classifications.iterator().next();
assert classification.getLastUpdated() != null;
assert classification.getLastUpdatedBy() != null;
Collection<ClassificationReference> references = classification.getReferences();
assert references != null;
assert references.size() == 5;
int releaseMatches = 0;
int trackMatches = 0;
for (ClassificationReference reference : references) {