### Question:
ServiceAdminManager { public JSONObject updateService(JSONObject jo) throws UnknownServiceException, InvalidServiceDescriptionException, JSONException, WebApplicationException, ConfigurationException, ParseException { try { new RegistrationValidator().validateInfo(jo); } catch(InvalidServiceDescriptionException e){ if (EMIRServer.getServerProperties().isGlobalEnabled() && jo.length() == 3 && jo.has(ServiceBasicAttributeNames.SERVICE_ENDPOINT_ID .getAttributeName()) && jo.has(ServiceBasicAttributeNames.SERVICE_UPDATE_SINCE .getAttributeName()) && jo.has(ServiceBasicAttributeNames.SERVICE_OWNER_DN .getAttributeName())) { String sendpointID = jo.getString(ServiceBasicAttributeNames.SERVICE_ENDPOINT_ID .getAttributeName()); String messageTime = jo.getJSONObject(ServiceBasicAttributeNames.SERVICE_UPDATE_SINCE .getAttributeName()).getString("$date"); try { removeService(sendpointID, messageTime); } catch (MultipleResourceException e1) { Log.logException("", e1,log); } catch (NonExistingResourceException e1) { Log.logException("", e1,log); } catch (PersistentStoreFailureException e1) { Log.logException("", e1,log); } return null; } else { throw new InvalidServiceDescriptionException(); } } if (EMIRServer.getServerProperties().isGlobalEnabled() ) { new RegistrationValidator().validateEndpointIDInfo(jo); } Integer expTime = EMIRServer.getServerProperties().getIntValue(ServerProperties.PROP_RECORD_EXPIRY_DEFAULT); if (log.isDebugEnabled()) { log.debug("The expiry attribute is missing from the updated service information. The information will be expired in "+ expTime +"day from now"); } DateUtil.setExpiryTime(jo, expTime); if (!jo.has(ServiceBasicAttributeNames.SERVICE_CREATED_ON .getAttributeName())) { JSONObject date = new JSONObject(); date.put("$date", DateUtil.toUTCFormat(new Date())); jo.put(ServiceBasicAttributeNames.SERVICE_CREATED_ON .getAttributeName(), date); } if (!jo.has(ServiceBasicAttributeNames.SERVICE_UPDATE_SINCE .getAttributeName())) { jo = DateUtil.addDate(jo, ServiceBasicAttributeNames.SERVICE_UPDATE_SINCE .getAttributeName(), new Date()); } ServiceObject sObj = new ServiceObject(jo); try { serviceDB.update(sObj); return jo; } catch (MultipleResourceException e) { Log.logException("", e,log); } catch (NonExistingResourceException e) { throw new WebApplicationException(Status.CONFLICT); } catch (PersistentStoreFailureException e) { Log.logException("", e,log); } return null; } ServiceAdminManager();  ServiceAdminManager(MongoDBServiceDatabase mongoDB); JSONObject addService(JSONObject jo); void removeService(String endpointID, String messageTime); JSONObject updateService(JSONObject jo); JSONObject findServiceByUrl(String url); JSONObject findServiceByEndpointID(String endpointID); void removeExpiredEntries(); void removeAll(); List<ServiceObject> findAll(); boolean checkOwner(String owner, String sendpointID); boolean checkMessageGenerationTime(String messageTime, String sendpointID); void removeServices(JSONObject query);  }### Answer:
@Test public void updateService() throws Exception { String id = "emi-es-id"; JSONObject jo = TestValueConstants.getJSONWithMandatoryAttributes(); jo.put(ServiceBasicAttributeNames.SERVICE_ENDPOINT_ID.getAttributeName(), id); adminMgr.addService(jo); jo.put(ServiceBasicAttributeNames.SERVICE_ENDPOINT_IFACENAME.getAttributeName(), "emi-es"); assertNotNull(adminMgr.updateService(jo)); System.out.println("service endpoint record updated"); assertEquals("emi-es", adminMgr.findServiceByEndpointID(id).get(ServiceBasicAttributeNames.SERVICE_ENDPOINT_IFACENAME.getAttributeName())); }