コード例 #1
0
func TestObjFindEventsByType(t *testing.T) {
	obj := models.NewIntellectualObject()

	// Add a creation event
	creationEvent := testutil.MakePremisEvent()
	creationEvent.EventType = constants.EventCreation
	obj.PremisEvents = append(obj.PremisEvents, creationEvent)

	// Add identifier assignment event
	idEvent := testutil.MakePremisEvent()
	idEvent.EventType = constants.EventIdentifierAssignment
	obj.PremisEvents = append(obj.PremisEvents, idEvent)

	// Add an ingest event
	ingestEvent := testutil.MakePremisEvent()
	ingestEvent.EventType = constants.EventIngestion
	obj.PremisEvents = append(obj.PremisEvents, ingestEvent)

	creationEvents := obj.FindEventsByType(constants.EventCreation)
	idEvents := obj.FindEventsByType(constants.EventIdentifierAssignment)
	ingestEvents := obj.FindEventsByType(constants.EventIngestion)

	require.Equal(t, 1, len(creationEvents))
	require.Equal(t, 1, len(idEvents))
	require.Equal(t, 1, len(ingestEvents))

	assert.Equal(t, creationEvent.Identifier, creationEvents[0].Identifier)
	assert.Equal(t, idEvent.Identifier, idEvents[0].Identifier)
	assert.Equal(t, ingestEvent.Identifier, ingestEvents[0].Identifier)
}
コード例 #2
0
func TestNewIntellectualObject(t *testing.T) {
	obj := models.NewIntellectualObject()
	assert.NotNil(t, obj.GenericFiles)
	assert.NotNil(t, obj.PremisEvents)
	assert.NotNil(t, obj.IngestFilesIgnored)
	assert.NotNil(t, obj.IngestTags)
}
コード例 #3
0
func getEmptyValidationResult() *validation.ValidationResult {
	return &validation.ValidationResult{
		ParseSummary:       models.NewWorkSummary(),
		ValidationSummary:  models.NewWorkSummary(),
		IntellectualObject: models.NewIntellectualObject(),
	}
}
コード例 #4
0
func TestFindTag(t *testing.T) {
	obj := models.NewIntellectualObject()
	obj.IngestTags = append(obj.IngestTags, models.NewTag("file1", "label1", "value1"))
	obj.IngestTags = append(obj.IngestTags, models.NewTag("file2", "label2", "value2"))
	obj.IngestTags = append(obj.IngestTags, models.NewTag("file3", "label3", "value3.0"))
	obj.IngestTags = append(obj.IngestTags, models.NewTag("file3", "label3", "value3.1"))
	obj.IngestTags = append(obj.IngestTags, models.NewTag("file4", "label3", "value3.2"))

	tags1 := obj.FindTag("label1")
	tags2 := obj.FindTag("label2")
	tags3 := obj.FindTag("label3")
	tagsx := obj.FindTag("Elmer Fudd")

	require.NotNil(t, tags1)
	assert.Equal(t, "value1", tags1[0].Value)
	require.NotNil(t, tags2)
	assert.Equal(t, "value2", tags2[0].Value)
	require.NotNil(t, tags3)
	assert.Equal(t, 3, len(tags3))
	assert.Equal(t, "value3.0", tags3[0].Value)
	assert.Equal(t, "value3.1", tags3[1].Value)
	assert.Equal(t, "value3.2", tags3[2].Value)
	assert.Nil(t, tagsx)
}