/** TDD. */ @Test(expected = IllegalArgumentException.class) public void updateKOempty() { // When testedStore.updateProperty("", "aa"); }
/** TDD. */ @Test(expected = IllegalArgumentException.class) public void updateKOnull() { // When testedStore.updateProperty(null, "aa"); }
/** TDD. */ @Test(expected = IllegalArgumentException.class) public void updateKONullBis() { // When testedStore.updateProperty(null); }
/** TDD. */ @Test(expected = PropertyNotFoundException.class) public void updateKOPropertyNotFound() { // When PropertyString ps = new PropertyString("does-not-exist"); testedStore.updateProperty(ps); }
public void updatePropertyName(String propertyName, String newValue) { propertyValidator.assertPropertyExist(propertyName); ff4j.getPropertiesStore().updateProperty(propertyName, newValue); } }
/** * Convenient method to update partially the feature: Here enabling * * @return http response. */ @POST @Path("/" + OPERATION_UPDATE) @RolesAllowed({ROLE_WRITE}) @ApiOperation(value= "Update a property", response=Response.class) @ApiResponses({ @ApiResponse(code = 204, message= "Property has been updated"), @ApiResponse(code = 404, message= "Property not found"), @ApiResponse(code = 400, message= "Invalid new value") }) public Response operationUpdate(@PathParam("name") String name, @PathParam("groupName") String newValue) { if (!ff4j.getPropertiesStore().existProperty(name)) { String errMsg = new FeatureNotFoundException(name).getMessage(); return Response.status(Response.Status.NOT_FOUND).entity(errMsg).build(); } getPropertyStore().updateProperty(name, newValue); return Response.noContent().build(); }
/** TDD. */ @Test(expected = IllegalArgumentException.class) public void updateKOInvalidValue() { // Given testedStore.createProperty(new PropertyLogLevel("updateKOInvalidValue", LogLevel.ERROR)); // When testedStore.updateProperty("updateKOInvalidValue", "KO"); }
getPropertyStore().updateProperty(property); return Response.noContent().build();
/** TDD. */ @Test(expected = PropertyNotFoundException.class) public void updateKOdoesnotExist() { // Given Assert.assertFalse(testedStore.existProperty(INVALID)); // When testedStore.updateProperty(INVALID, "aa"); }
/** {@inheritDoc} */ public void updateProperty(String name, String newValue) { long start = System.nanoTime(); target.updateProperty(name, newValue); long duration = System.nanoTime() - start; publish(builder(ACTION_UPDATE) .property(name) .value(newValue) .duration(duration)); }
private void processCommandUpdateProperty(String commandLine) { try { CommandLine cmd = CMD_PARSER.parse(propertyOptions(), commandLine.split(" ")); if (cmd.getArgList().size() != 1 || !cmd.hasOption("p") || !cmd.hasOption("v")) { logError("Invalid command, expecting update -p <property> -v <value>"); } else { String property = cmd.getOptionValue('p'); String value = cmd.getOptionValue('v'); if (!currentFF4J.getPropertiesStore().existProperty(property)) { logWarn("Property " + property + " does not exist, nothing to update"); } else { currentFF4J.getPropertiesStore().updateProperty(property, value); logInfo("Property " + property + " has been updated with " + value); } } } catch (ParseException e) { error(e, "parsing error during update property command"); } catch (Exception e) { error(e, "Cannot update property"); } }
for (Entry<String, Property<?>> p : mapsOfProperties.entrySet()) { if (pstore.existProperty(p.getKey())) { pstore.updateProperty(p.getValue()); } else { pstore.createProperty(p.getValue());
/** {@inheritDoc} */ public <T> void updateProperty(Property<T> prop) { long start = System.nanoTime(); target.updateProperty(prop); long duration = System.nanoTime() - start; publish(builder(ACTION_UPDATE) .property(prop.getName()) .value(prop.asString()) .duration(duration)); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void setProperty(String key, Object value) { if (!ff4jStore.existProperty(key)) { addProperty(key, value); } Property<Object> ap = (Property<Object>) ff4jStore().readProperty(key); ap.setValue(String.valueOf(value)); ff4jStore().updateProperty(ap); }
/** {@inheritDoc} */ @Override public <T> void updateProperty(Property<T> propertyValue) { // Update the property getTargetPropertyStore().updateProperty(propertyValue); // Update the cache accordirly getCacheManager().evictProperty(propertyValue.getName()); // Update the property in cache getCacheManager().putProperty(propertyValue); }
/** {@inheritDoc} */ public void get(HttpServletRequest req, HttpServletResponse res, WebContext ctx) throws IOException { String operation = req.getParameter(WebConstants.OPERATION); String propertyName = req.getParameter(WebConstants.FEATID); String msgType = "success"; String msg = null; if (Util.hasLength(operation) && Util.hasLength(propertyName) && getFf4j().getPropertiesStore().existProperty(propertyName)) { if (OP_DELETE_FIXEDVALUE.equalsIgnoreCase(operation)) { String fixedValue = req.getParameter(PARAM_FIXEDVALUE); Property<?> ap = getFf4j().getPropertiesStore().readProperty(propertyName); // Need to convert back to object to use the remove() ap.getFixedValues().remove(ap.fromString(fixedValue)); getFf4j().getPropertiesStore().updateProperty(ap); LOGGER.info("Property '" + propertyName + "' remove fixedValue '" + fixedValue + "'"); } if (OP_ADD_FIXEDVALUE.equalsIgnoreCase(operation)) { String fixedValue = req.getParameter(PARAM_FIXEDVALUE); Property<?> ap = getFf4j().getPropertiesStore().readProperty(propertyName); ap.add2FixedValueFromString(fixedValue); getFf4j().getPropertiesStore().updateProperty(ap); LOGGER.info("Property '" + propertyName + "' add fixedValue '" + fixedValue + "'"); } } ctx.setVariable("msgType", msgType); ctx.setVariable("msgInfo", msg); renderPage(ctx); }
/** TDD. */ @Test public void updateOK() { // Given testedStore.createProperty(new PropertyLogLevel(UPDATE_OK, LogLevel.ERROR)); // When testedStore.updateProperty(UPDATE_OK, "INFO"); // Then Assert.assertEquals(LogLevel.INFO, testedStore.readProperty(UPDATE_OK).getValue()); }
/** TDD. */ @Test public void updateOKProperties() { // Given testedStore.createProperty(new PropertyLogLevel("logX", LogLevel.ERROR)); // When PropertyLogLevel pll = new PropertyLogLevel("logX", LogLevel.INFO); testedStore.updateProperty(pll); // Then Assert.assertEquals(LogLevel.INFO, testedStore.readProperty("logX").getValue()); }
/** {@inheritDoc} */ @Override public void updateProperty(String name, String newValue) { // Retrieve the full object from its name Property<?> fp = getTargetPropertyStore().readProperty(name); fp.setValueFromString(newValue); // Update value in target store getTargetPropertyStore().updateProperty(fp); // Remove from cache old value getCacheManager().evictProperty(fp.getName()); // Add new value in the cache getCacheManager().putProperty(fp); }
public FeatureActions createOrUpdateProperty(String propertyName, PropertyApiBean propertyApiBean) { propertyValidator.assertPropertyNameNotBlank(propertyApiBean.getName()); propertyValidator.assertPropertyNameMatch(propertyName, propertyApiBean.getName()); Property<?> property = propertyApiBean.asProperty(); if (ff4j.getPropertiesStore().existProperty(propertyName)) { ff4j.getPropertiesStore().updateProperty(property); return FeatureActions.UPDATED; } else { ff4j.getPropertiesStore().createProperty(property); return FeatureActions.CREATED; } }