+ InfoCoordinatorAddress: "https://informationservice:8434",
+ DMaaPMRAddress: "https://message-router.onap:3905",
+ KafkaBootstrapServers: "localhost:9092",
+ ProducerCertPath: "security/producer.crt",
+ ProducerKeyPath: "security/producer.key",
+ }
+
+ got := New()
+
+ assertions.Equal(&wantConfig, got)
+ logString := buf.String()
+ assertions.Contains(logString, "Invalid log level: wrong. Log level will be Info!")
+}
+
+func TestGetJobTypesFromConfiguration_fileOkShouldReturnSliceOfTypeDefinitions(t *testing.T) {
+ assertions := require.New(t)
+ typesDir := CreateTypeConfigFiles(t)
+ t.Cleanup(func() {
+ os.RemoveAll(typesDir)
+ })
+
+ var typeSchemaObj interface{}
+ json.Unmarshal([]byte(typeSchemaFileContent), &typeSchemaObj)
+
+ types, err := GetJobTypesFromConfiguration(typesDir)
+
+ wantedDMaaPType := TypeDefinition{
+ Identity: "type1",
+ DMaaPTopicURL: "events/unauthenticated.SEC_FAULT_OUTPUT/dmaapmediatorproducer/type1",
+ TypeSchema: typeSchemaObj,
+ }
+ wantedKafkaType := TypeDefinition{
+ Identity: "type2",
+ KafkaInputTopic: "TestTopic",
+ TypeSchema: typeSchemaObj,
+ }
+ wantedTypes := []TypeDefinition{wantedDMaaPType, wantedKafkaType}
+ assertions.EqualValues(wantedTypes, types)
+ assertions.Nil(err)
+}
+
+const typeDefinition = `{"types": [{"id": "type1", "dmaapTopicUrl": "events/unauthenticated.SEC_FAULT_OUTPUT/dmaapmediatorproducer/type1"}, {"id": "type2", "kafkaInputTopic": "TestTopic"}]}`
+const typeSchemaFileContent = `{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "filter": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }`
+
+func CreateTypeConfigFiles(t *testing.T) string {
+ typesDir, err := os.MkdirTemp("", "configs")
+ if err != nil {
+ t.Errorf("Unable to create temporary directory for types due to: %v", err)
+ }
+ fname := filepath.Join(typesDir, "type_config.json")
+ if err = os.WriteFile(fname, []byte(typeDefinition), 0666); err != nil {
+ t.Errorf("Unable to create temporary config file for types due to: %v", err)
+ }
+ fname = filepath.Join(typesDir, "typeSchemaDmaap.json")
+ if err = os.WriteFile(fname, []byte(typeSchemaFileContent), 0666); err != nil {
+ t.Errorf("Unable to create temporary schema file for DMaaP type due to: %v", err)