@@ -49,7 +49,7 @@ public void remoteCreate() throws HygieiaException {
49
49
ObjectId objectId = ObjectId .get ();
50
50
expected .setId (objectId );
51
51
CmdbRequest request = makeCmdbRequest ("BAPTEST" , "subtype" ,
52
- "type" , "assignmentgroup" ,"owner" , "BAPTEST" , "" , "cmdbCollector" );
52
+ "type" , "assignmentgroup" ,"owner" , "BAPTEST" , null , "" , "cmdbCollector" );
53
53
when (cmdbRepository .findByConfigurationItemAndItemType ("" ,"" )).thenReturn (null );
54
54
when (collectorService .createCollectorItem (Matchers .any (CollectorItem .class ) )).thenReturn (makeCollectorItem ());
55
55
when (collectorRepository .findByCollectorTypeAndName (CollectorType .CMDB , request .getToolName ())).thenReturn (makeCollector ( request .getToolName (), CollectorType .CMDB ));
@@ -69,7 +69,7 @@ public void remoteCreateInvalidBusService() throws HygieiaException {
69
69
ObjectId objectId = ObjectId .get ();
70
70
expected .setId (objectId );
71
71
CmdbRequest request = makeCmdbRequest ("BAPTEST" , "subtype" ,
72
- "type" , "assignmentgroup" ,"owner" , "BAPTEST" , "ASVTEST" , "cmdbCollector" );
72
+ "type" , "assignmentgroup" ,"owner" , "BAPTEST" , null , "ASVTEST" , "cmdbCollector" );
73
73
when (cmdbRepository .findByConfigurationItemAndItemType ("" ,"" )).thenReturn (null );
74
74
when (collectorService .createCollectorItem (Matchers .any (CollectorItem .class ) )).thenReturn (makeCollectorItem ());
75
75
when (collectorRepository .findByCollectorTypeAndName (CollectorType .CMDB , request .getToolName ())).thenReturn (makeCollector ( request .getToolName (), CollectorType .CMDB ));
@@ -84,6 +84,29 @@ public void remoteCreateInvalidBusService() throws HygieiaException {
84
84
assertEquals (excep .getMessage (), e .getMessage ());
85
85
}
86
86
}
87
+
88
+ /**
89
+ * Test the use of businessService instead of configurationItemBusServName in the request.
90
+ * @throws HygieiaException
91
+ */
92
+ @ Test
93
+ public void remoteCreateUsingBusinessService () throws HygieiaException {
94
+ Cmdb businessServiceItem = makeCmdbItem ("CI123456" , "subtype" ,
95
+ "type" , "assignmentgroup" ,"owner" , "ASVTEST" );
96
+ Cmdb expected = makeCmdbItem ("BAPTEST" , "subtype" ,
97
+ "type" , "assignmentgroup" ,"owner" , "BAPTEST" );
98
+ ObjectId objectId = ObjectId .get ();
99
+ expected .setId (objectId );
100
+ CmdbRequest request = makeCmdbRequest ("BAPTEST" , "subtype" ,
101
+ "type" , "assignmentgroup" ,"owner" , "BAPTEST" , "CI123456" , "" , "cmdbCollector" );
102
+ when (cmdbRepository .findByConfigurationItemAndItemType ("CI123456" ,"app" )).thenReturn (businessServiceItem );
103
+ when (collectorService .createCollectorItem (Matchers .any (CollectorItem .class ) )).thenReturn (makeCollectorItem ());
104
+ when (collectorRepository .findByCollectorTypeAndName (CollectorType .CMDB , request .getToolName ())).thenReturn (makeCollector ( request .getToolName (), CollectorType .CMDB ));
105
+ when (cmdbRepository .save (Matchers .any (Cmdb .class ))).thenReturn (expected );
106
+
107
+ assertThat (cmdbRemoteService .remoteCreate (request ), is (expected ));
108
+ }
109
+
87
110
/**
88
111
* Tests remoteCreate functionality ConfigurationItemBusServName doesn't have existing relationships
89
112
* @throws HygieiaException
@@ -97,7 +120,7 @@ public void remoteCreateRelationshipUpdateExistingCompsNull() throws HygieiaExce
97
120
ObjectId objectId = ObjectId .get ();
98
121
expected .setId (objectId );
99
122
CmdbRequest request = makeCmdbRequest ("BAPTEST" , "subtype" ,
100
- "type" , "assignmentgroup" ,"owner" , "BAPTEST" , "ASVTEST" , "cmdbCollector" );
123
+ "type" , "assignmentgroup" ,"owner" , "BAPTEST" , null , "ASVTEST" , "cmdbCollector" );
101
124
when (cmdbRepository .findByConfigurationItemAndItemType ("" ,"" )).thenReturn (null );
102
125
when (collectorService .createCollectorItem (Matchers .any (CollectorItem .class ) )).thenReturn (makeCollectorItem ());
103
126
when (collectorRepository .findByCollectorTypeAndName (CollectorType .CMDB , request .getToolName ())).thenReturn (makeCollector ( request .getToolName (), CollectorType .CMDB ));
@@ -122,7 +145,7 @@ public void remoteCreateRelationshipUpdateExistingComps() throws HygieiaExceptio
122
145
ObjectId objectId = ObjectId .get ();
123
146
expected .setId (objectId );
124
147
CmdbRequest request = makeCmdbRequest ("BAPTEST" , "subtype" ,
125
- "type" , "assignmentgroup" ,"owner" , "BAPTEST" , "ASVTEST" , "cmdbCollector" );
148
+ "type" , "assignmentgroup" ,"owner" , "BAPTEST" , null , "ASVTEST" , "cmdbCollector" );
126
149
when (cmdbRepository .findByConfigurationItemAndItemType ("" ,"" )).thenReturn (null );
127
150
when (collectorService .createCollectorItem (Matchers .any (CollectorItem .class ) )).thenReturn (makeCollectorItem ());
128
151
when (collectorRepository .findByCollectorTypeAndName (CollectorType .CMDB , request .getToolName ())).thenReturn (makeCollector ( request .getToolName (), CollectorType .CMDB ));
@@ -154,6 +177,7 @@ private CmdbRequest makeCmdbRequest(String configurationItem,
154
177
String assignmentGroup ,
155
178
String ownerDept ,
156
179
String commonName ,
180
+ String businessService ,
157
181
String configurationItemBusServName ,
158
182
String toolName ){
159
183
@@ -164,6 +188,7 @@ private CmdbRequest makeCmdbRequest(String configurationItem,
164
188
request .setAssignmentGroup (assignmentGroup );
165
189
request .setOwnerDept (ownerDept );
166
190
request .setCommonName (commonName );
191
+ request .setBusinessService (businessService );
167
192
request .setConfigurationItemBusServName (configurationItemBusServName );
168
193
request .setToolName (toolName );
169
194
return request ;
0 commit comments