@@ -49,7 +49,7 @@ describe('Merge custom properties tests', () => {
4949 const { value, output } = await flowNode . mergeCustomProperties ( {
5050 customProperties : JSON . parse ( fs . readFileSync ( './test/testInput/customPropertiesConfig.json' ) , null ) ,
5151 desiredIndexTemplate : desiredIndexTemplate ,
52- mergeCustomProperties : false
52+ customPropertiesSettings : { merge : false }
5353 } ) ;
5454
5555 expect ( output ) . to . equal ( 'noUpdate' ) ;
@@ -60,12 +60,12 @@ describe('Merge custom properties tests', () => {
6060 const { value, output } = await flowNode . mergeCustomProperties ( {
6161 customProperties : JSON . parse ( fs . readFileSync ( './test/testInput/customPropertiesConfig.json' ) , null ) ,
6262 desiredIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/desiredIndexTemplate.json' ) , null ) ,
63- mergeCustomProperties : true
63+ customPropertiesSettings : { merge : true , parent : "" }
6464 } ) ;
6565
6666 expect ( output ) . to . equal ( 'next' ) ;
6767 expect ( value . mappings . properties [ 'customProperties.customProperty1' ] ) . to . be . an ( 'Object' ) ;
68- expect ( value . mappings . properties [ 'customProperties.customProperty1' ] . type ) . to . equal ( ' text' ) ;
68+ expect ( value . mappings . properties [ 'customProperties.customProperty1' ] ) . to . deep . equal ( { type : " text" , norms : false , fields : { keyword : { type : "keyword" } } } ) ;
6969 expect ( value . mappings . properties [ 'customProperties.customProperty2' ] ) . to . be . an ( 'Object' ) ;
7070 expect ( value . mappings . properties [ 'customProperties.customProperty2' ] . type ) . to . equal ( 'keyword' ) ;
7171 expect ( value . mappings . properties [ 'customProperties.customProperty3' ] ) . to . be . an ( 'Object' ) ;
@@ -77,11 +77,11 @@ describe('Merge custom properties tests', () => {
7777 customProperties : JSON . parse ( fs . readFileSync ( './test/testInput/customPropertiesConfig.json' ) , null ) ,
7878 desiredIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/desiredIndexTemplate.json' ) , null ) ,
7979 actualIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/actualIndexTemplate.json' ) , null ) ,
80- mergeCustomProperties : true
80+ customPropertiesSettings : { merge : true , parent : "" }
8181 } ) ;
8282 expect ( output ) . to . equal ( 'next' ) ;
8383 expect ( value . mappings . properties [ 'customProperties.customProperty1' ] ) . to . be . an ( 'Object' ) ;
84- expect ( value . mappings . properties [ 'customProperties.customProperty1' ] . type ) . to . equal ( ' text' ) ;
84+ expect ( value . mappings . properties [ 'customProperties.customProperty1' ] ) . to . deep . equal ( { type : " text" , norms : false , fields : { keyword : { type : "keyword" } } } ) ;
8585 expect ( value . mappings . properties [ 'customProperties.customProperty2' ] ) . to . be . an ( 'Object' ) ;
8686 expect ( value . mappings . properties [ 'customProperties.customProperty2' ] . type ) . to . equal ( 'keyword' ) ;
8787 expect ( value . mappings . properties [ 'customProperties.customProperty3' ] ) . to . be . an ( 'Object' ) ;
@@ -93,11 +93,11 @@ describe('Merge custom properties tests', () => {
9393 customProperties : JSON . parse ( fs . readFileSync ( './test/testInput/customPropertiesConfig.json' ) , null ) ,
9494 desiredIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/desiredIndexTemplateWithCustomProps.json' ) , null ) ,
9595 actualIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/actualIndexTemplateWithCustomProps.json' ) , null ) ,
96- mergeCustomProperties : true
96+ customPropertiesSettings : { merge : true , parent : "" }
9797 } ) ;
9898 expect ( output ) . to . equal ( 'noUpdate' ) ;
9999 expect ( value . mappings . properties [ 'customProperties.customProperty1' ] ) . to . be . an ( 'Object' ) ;
100- expect ( value . mappings . properties [ 'customProperties.customProperty1' ] . type ) . to . equal ( ' text' ) ;
100+ expect ( value . mappings . properties [ 'customProperties.customProperty1' ] ) . to . deep . equal ( { type : " text" } ) ;
101101 expect ( value . mappings . properties [ 'customProperties.customProperty2' ] ) . to . be . an ( 'Object' ) ;
102102 expect ( value . mappings . properties [ 'customProperties.customProperty2' ] . type ) . to . equal ( 'keyword' ) ;
103103 expect ( value . mappings . properties [ 'customProperties.customProperty3' ] ) . to . be . an ( 'Object' ) ;
@@ -109,15 +109,32 @@ describe('Merge custom properties tests', () => {
109109 customProperties : JSON . parse ( fs . readFileSync ( './test/testInput/customPropertiesConfig.json' ) , null ) ,
110110 desiredIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/desiredIndexTemplate.json' ) , null ) ,
111111 actualIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/actualIndexTemplateWithLessCustomProps.json' ) , null ) ,
112- mergeCustomProperties : true
112+ customPropertiesSettings : { merge : true , parent : "" }
113113 } ) ;
114114 expect ( output ) . to . equal ( 'next' ) ;
115115 expect ( value . mappings . properties [ 'customProperties.customProperty1' ] ) . to . be . an ( 'Object' ) ;
116- expect ( value . mappings . properties [ 'customProperties.customProperty1' ] . type ) . to . equal ( ' text' ) ;
116+ expect ( value . mappings . properties [ 'customProperties.customProperty1' ] ) . to . deep . equal ( { type : " text" , norms : false , fields : { keyword : { type : "keyword" } } } ) ;
117117 expect ( value . mappings . properties [ 'customProperties.customProperty2' ] ) . to . be . an ( 'Object' ) ;
118118 expect ( value . mappings . properties [ 'customProperties.customProperty2' ] . type ) . to . equal ( 'keyword' ) ;
119119 expect ( value . mappings . properties [ 'customProperties.customProperty3' ] ) . to . be . an ( 'Object' ) ;
120120 expect ( value . mappings . properties [ 'customProperties.customProperty3' ] . type ) . to . equal ( 'keyword' ) ;
121121 } ) ;
122+
123+ it ( 'should merge into indexMappingTemplate withd a defined parent as custom properties are missing' , async ( ) => {
124+ const { value, output } = await flowNode . mergeCustomProperties ( {
125+ customProperties : JSON . parse ( fs . readFileSync ( './test/testInput/customPropertiesConfig.json' ) , null ) ,
126+ desiredIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/desiredIndexTemplate.json' ) , null ) ,
127+ actualIndexTemplate : JSON . parse ( fs . readFileSync ( './test/testInput/actualIndexTemplate.json' ) , null ) ,
128+ customPropertiesSettings : { merge : true , parent : "transactionSummary" }
129+ } ) ;
130+
131+ expect ( output ) . to . equal ( 'next' ) ;
132+ expect ( value . mappings . properties . transactionSummary [ 'customProperties.customProperty1' ] ) . to . be . an ( 'Object' ) ;
133+ expect ( value . mappings . properties . transactionSummary [ 'customProperties.customProperty1' ] ) . to . deep . equal ( { type : "text" , norms : false , fields : { keyword : { type : "keyword" } } } ) ;
134+ expect ( value . mappings . properties . transactionSummary [ 'customProperties.customProperty2' ] ) . to . be . an ( 'Object' ) ;
135+ expect ( value . mappings . properties . transactionSummary [ 'customProperties.customProperty2' ] . type ) . to . equal ( 'keyword' ) ;
136+ expect ( value . mappings . properties . transactionSummary [ 'customProperties.customProperty3' ] ) . to . be . an ( 'Object' ) ;
137+ expect ( value . mappings . properties . transactionSummary [ 'customProperties.customProperty3' ] . type ) . to . equal ( 'keyword' ) ;
138+ } ) ;
122139 } ) ;
123140} ) ;
0 commit comments