/** {@inheritDoc} */ @Override public boolean existGroup(String groupName) { return target.existGroup(groupName); }
/** {@inheritDoc} */ @Override public boolean existGroup(String groupName) { // Cache cannot help you return getTargetFeatureStore().existGroup(groupName); }
/** * TDD. */ @Test(expected = IllegalArgumentException.class) public void testExistGroupNull() throws Exception { // Given // When testedStore.existGroup(null); // Then, expected error... }
/** * TDD. */ @Test(expected = IllegalArgumentException.class) public void testExistGroupEmpty() throws Exception { // Given // When testedStore.existGroup(""); // Then, expected error... }
public void assertGroupExist(String groupName) { if (!ff4j.getFeatureStore().existGroup(groupName)) { throw new GroupNotExistsException(); } } }
public void assertGroupDoesNotExist(String groupName) { if (ff4j.getFeatureStore().existGroup(groupName)) { throw new GroupExistsException(); } }
/** * TDD. */ @Test public void testExistGroup() { // Given assertFf4j.assertThatGroupExist(G1); assertFf4j.assertThatGroupDoesNotExist(G_DOESNOTEXIST); // Then Assert.assertTrue(testedStore.existGroup(G1)); Assert.assertFalse(testedStore.existGroup(G_DOESNOTEXIST)); }
/** * Convenient method to update partially the feature: Removing from a group * * @return http response. */ @POST @RolesAllowed({ROLE_WRITE}) @Path("/" + OPERATION_REMOVEGROUP + "/{groupName}") @ApiOperation(value= "Remove the group of the feature", response=Response.class) @ApiResponses({ @ApiResponse(code = 204, message= "Group has been removed"), @ApiResponse(code = 404, message= "Feature not found"), @ApiResponse(code = 400, message= "Invalid GroupName") }) public Response operationRemoveGroup(@PathParam("uid") String id, @PathParam("groupName") String groupName) { if (!ff4j.getFeatureStore().exist(id)) { String errMsg = new FeatureNotFoundException(id).getMessage(); return Response.status(Response.Status.NOT_FOUND).entity(errMsg).build(); } // Expected behaviour is no error even if invalid groupname // .. but invalid if group does not exist... if (!ff4j.getFeatureStore().existGroup(groupName)) { String errMsg = "Invalid groupName should be " + groupName; return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); } getFeatureStore().removeFromGroup(id, groupName); return Response.noContent().build(); }
/** * Check that group does not exist * * @param expected * expected value for size * @param groupName * target groupName * @return current object */ public AssertFf4j assertThatGroupDoesNotExist(String groupName) { waitSomeSeconds(); Assert.assertFalse("Group '" + groupName + " ' does no exist", ff4j.getFeatureStore().existGroup(groupName)); return this; }
/** * Check Group Size * * @param expected * expected value for size * @param groupName * target groupName * @return current object */ public final AssertFf4j assertThatGroupExist(String groupName) { Assert.assertTrue("Group '" + groupName + " ' does no exist", ff4j.getFeatureStore().existGroup(groupName)); waitSomeSeconds(); return this; }
private void processCommandEnableGroup(String commandLine, boolean enable) { try { CommandLine cmd = CMD_PARSER.parse(enableGroupOptions(), commandLine.split(" ")); if (cmd.getArgList().size() != 1 || !cmd.hasOption("g") ) { logWarn("Invalid command, expecting enableGroup/disableGroup -f <groupName>"); } else { String groupName = cmd.getOptionValue('g'); if (!currentFF4J.getFeatureStore().existGroup(groupName)) { logWarn("Group [" + groupName + "] not found"); } else if (enable){ currentFF4J.getFeatureStore().enableGroup(groupName); logInfo("Group " + groupName + " is now enabled") ; } else { currentFF4J.getFeatureStore().disableGroup(groupName); logInfo("Group " + groupName + " is now disabled") ; } } } catch (ParseException e) { error(e, ERROR_DURING_CONNECT_COMMAND); } }