Loading src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java +17 Changes for src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java: 17 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -925,6 +925,23 @@ public class ServiceOrderRepoService { } } else if ( ( originChar != null ) && ( originChar.getValue() == null ) && ( updChar.getValue() != null ) ) { originChar.setValue( new Any( updChar.getValue() ) ); } else if ( originChar == null ) { /** * A characteristic the item does not carry yet: add it, rather than dropping it * silently. A client amending an order frequently needs to set a characteristic * the ordered service was never given a value for, and ignoring it would leave * the order asking for something other than what was requested — with nothing in * the response to say so. */ Characteristic newChar = new Characteristic(); newChar.setName( charname ); newChar.setValueType( updChar.getValueType() ); if ( updChar.getValue() != null ) { newChar.setValue( new Any( updChar.getValue() ) ); } soiOrigin.getService().addServiceCharacteristicItem( newChar ); logger.info("Order item " + soiOrigin.getUuid() + ": characteristic " + charname + " added by update"); } } Loading src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java +71 Changes for src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java: 71 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -625,6 +625,77 @@ public class ServiceOrderRepoServiceTest extends BaseIT { } /** * An existing order item is updated with characteristics it does not carry yet (#107). * Before the fix, a characteristic unknown to the item was silently dropped. */ @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) @Test public void testUpdateServiceOrderAddsNewCharacteristicToOrderItem() throws Exception { ServiceOrder createdServiceOrder = JsonUtils.toJsonObj(createServiceOrder(), ServiceOrder.class); String soId = createdServiceOrder.getId(); String itemId = createdServiceOrder.getOrderItem().iterator().next().getId(); // the item has no characteristics: add one with a value and one without Characteristic newChar = new Characteristic(); newChar.setName("newChar"); newChar.setValueType("TEXT"); newChar.setValue(new Any("newValue", "newAlias")); Characteristic newCharNoValue = new Characteristic(); newCharNoValue.setName("newCharNoValue"); serviceOrderRepoService.updateServiceOrder(soId, characteristicsUpdate(itemId, newChar, newCharNoValue)); ServiceOrderItem updatedItem = JsonUtils.toJsonObj( serviceOrderRepoService.getServiceOrderEagerAsString(soId), ServiceOrder.class).findOrderItemById(itemId); assertThat(updatedItem.getService().getServiceCharacteristic()).hasSize(2); Characteristic addedChar = updatedItem.getService().findCharacteristicByName("newChar"); assertThat(addedChar).isNotNull(); assertThat(addedChar.getValueType()).isEqualTo("TEXT"); assertThat(addedChar.getValue().getValue()).isEqualTo("newValue"); assertThat(addedChar.getValue().getAlias()).isEqualTo("newAlias"); assertThat(updatedItem.getService().findCharacteristicByName("newCharNoValue")).isNotNull(); // the added characteristic is now updated in place, not added a second time Characteristic changedChar = new Characteristic(); changedChar.setName("newChar"); changedChar.setValue(new Any("changedValue", "changedAlias")); serviceOrderRepoService.updateServiceOrder(soId, characteristicsUpdate(itemId, changedChar)); updatedItem = JsonUtils.toJsonObj( serviceOrderRepoService.getServiceOrderEagerAsString(soId), ServiceOrder.class).findOrderItemById(itemId); assertThat(updatedItem.getService().getServiceCharacteristic()).hasSize(2); assertThat(updatedItem.getService().findCharacteristicByName("newChar").getValue().getValue()) .isEqualTo("changedValue"); } /** * An update of an existing order item that carries only its id and the given characteristics */ private ServiceOrderUpdate characteristicsUpdate(String itemId, Characteristic... characteristics) { ServiceRestriction serviceRestriction = new ServiceRestriction(); serviceRestriction.setName("aServiceRestriction"); for (Characteristic c : characteristics) { serviceRestriction.addServiceCharacteristicItem(c); } ServiceOrderItem soi = new ServiceOrderItem(); soi.setUuid(itemId); soi.setService(serviceRestriction); ServiceOrderUpdate servOrderUpd = new ServiceOrderUpdate(); servOrderUpd.addOrderItemItem(soi); return servOrderUpd; } // // This test causes "HikariPool-1 - Connection is not available, request timed out after 30000ms" error for other tests // @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) // @Test Loading Loading
src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java +17 Changes for src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java: 17 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -925,6 +925,23 @@ public class ServiceOrderRepoService { } } else if ( ( originChar != null ) && ( originChar.getValue() == null ) && ( updChar.getValue() != null ) ) { originChar.setValue( new Any( updChar.getValue() ) ); } else if ( originChar == null ) { /** * A characteristic the item does not carry yet: add it, rather than dropping it * silently. A client amending an order frequently needs to set a characteristic * the ordered service was never given a value for, and ignoring it would leave * the order asking for something other than what was requested — with nothing in * the response to say so. */ Characteristic newChar = new Characteristic(); newChar.setName( charname ); newChar.setValueType( updChar.getValueType() ); if ( updChar.getValue() != null ) { newChar.setValue( new Any( updChar.getValue() ) ); } soiOrigin.getService().addServiceCharacteristicItem( newChar ); logger.info("Order item " + soiOrigin.getUuid() + ": characteristic " + charname + " added by update"); } } Loading
src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java +71 Changes for src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java: 71 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -625,6 +625,77 @@ public class ServiceOrderRepoServiceTest extends BaseIT { } /** * An existing order item is updated with characteristics it does not carry yet (#107). * Before the fix, a characteristic unknown to the item was silently dropped. */ @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) @Test public void testUpdateServiceOrderAddsNewCharacteristicToOrderItem() throws Exception { ServiceOrder createdServiceOrder = JsonUtils.toJsonObj(createServiceOrder(), ServiceOrder.class); String soId = createdServiceOrder.getId(); String itemId = createdServiceOrder.getOrderItem().iterator().next().getId(); // the item has no characteristics: add one with a value and one without Characteristic newChar = new Characteristic(); newChar.setName("newChar"); newChar.setValueType("TEXT"); newChar.setValue(new Any("newValue", "newAlias")); Characteristic newCharNoValue = new Characteristic(); newCharNoValue.setName("newCharNoValue"); serviceOrderRepoService.updateServiceOrder(soId, characteristicsUpdate(itemId, newChar, newCharNoValue)); ServiceOrderItem updatedItem = JsonUtils.toJsonObj( serviceOrderRepoService.getServiceOrderEagerAsString(soId), ServiceOrder.class).findOrderItemById(itemId); assertThat(updatedItem.getService().getServiceCharacteristic()).hasSize(2); Characteristic addedChar = updatedItem.getService().findCharacteristicByName("newChar"); assertThat(addedChar).isNotNull(); assertThat(addedChar.getValueType()).isEqualTo("TEXT"); assertThat(addedChar.getValue().getValue()).isEqualTo("newValue"); assertThat(addedChar.getValue().getAlias()).isEqualTo("newAlias"); assertThat(updatedItem.getService().findCharacteristicByName("newCharNoValue")).isNotNull(); // the added characteristic is now updated in place, not added a second time Characteristic changedChar = new Characteristic(); changedChar.setName("newChar"); changedChar.setValue(new Any("changedValue", "changedAlias")); serviceOrderRepoService.updateServiceOrder(soId, characteristicsUpdate(itemId, changedChar)); updatedItem = JsonUtils.toJsonObj( serviceOrderRepoService.getServiceOrderEagerAsString(soId), ServiceOrder.class).findOrderItemById(itemId); assertThat(updatedItem.getService().getServiceCharacteristic()).hasSize(2); assertThat(updatedItem.getService().findCharacteristicByName("newChar").getValue().getValue()) .isEqualTo("changedValue"); } /** * An update of an existing order item that carries only its id and the given characteristics */ private ServiceOrderUpdate characteristicsUpdate(String itemId, Characteristic... characteristics) { ServiceRestriction serviceRestriction = new ServiceRestriction(); serviceRestriction.setName("aServiceRestriction"); for (Characteristic c : characteristics) { serviceRestriction.addServiceCharacteristicItem(c); } ServiceOrderItem soi = new ServiceOrderItem(); soi.setUuid(itemId); soi.setService(serviceRestriction); ServiceOrderUpdate servOrderUpd = new ServiceOrderUpdate(); servOrderUpd.addOrderItemItem(soi); return servOrderUpd; } // // This test causes "HikariPool-1 - Connection is not available, request timed out after 30000ms" error for other tests // @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) // @Test Loading