/** Test delete smart point from tag. */ @Test public void testDeleteLightFromTag() { // Validation situation TagRequest tagRequest = new TagRequest(new UserContext(1)); Tag tag = new Tag(); TagResponse response = getTagBCF().deleteLightFromTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages( response, SENSUS_MLC_VALIDATOR_ID_REQUIRED, SENSUS_MLC_VALIDATOR_REQUIRED, SENSUS_MLC_VALIDATOR_ID_REQUIRED); // Success situation tagRequest = TestBaseUtil.createTagRequest(); Light light = TestBaseUtil.createLight(); List<Integer> lightIdsList = new ArrayList<Integer>(); lightIdsList.add(1); tag.getLights().add(light); List<Tag> tagList = new ArrayList<Tag>(); tagList.add(TestBaseUtil.createTag()); tagRequest.setTags(tagList); tagRequest.setPaginationAllSelected(true); tagRequest.setSelectionPaginationIds(lightIdsList); response = getTagBCF().deleteLightFromTag(tagRequest); assertTrue(response.isOperationSuccess()); // Exception situation resetMocksToTagArea(); setSituation(getTagBCF(), SituationsEnum.EXCEPTION, ITagBCL.class, DELETE_LIGHT_FROM_TAG); response = getTagBCF().deleteLightFromTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages(response, DEFAULT_TAG_BCF_EXCEPTION_MSG); // Error situation resetMocksToTagArea(); setSituation(getTagBCF(), SituationsEnum.ERROR, ITagBCL.class, DELETE_LIGHT_FROM_TAG); response = getTagBCF().deleteLightFromTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages(response, ERROR_CODE); // Error situation tagRequest = TestBaseUtil.createTagRequest(); response = getTagBCF().deleteLightFromTag(tagRequest); assertFalse(response.isOperationSuccess()); // Error situation tagRequest = TestBaseUtil.createTagRequest(); tag = TestBaseUtil.createTag(); tag.setId(null); lightIdsList = new ArrayList<Integer>(); lightIdsList.add(1); tagRequest.setTag(tag); tagRequest.setPaginationAllSelected(true); tagRequest.setSelectionPaginationIds(lightIdsList); response = getTagBCF().deleteLightFromTag(tagRequest); assertFalse(response.isOperationSuccess()); }
/** Test insert tag. */ @Test public void testInsertTag() { // Validation situation TagRequest tagRequest = new TagRequest(); TagResponse response = getTagBCF().insertTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages( response, SENSUS_MLC_VALIDATOR_ID_REQUIRED, SENSUS_MLC_VALIDATOR_REQUIRED, SENSUS_MLC_VALIDATOR_ID_REQUIRED); // Success situation tagRequest = TestBaseUtil.createTagRequest(); Tag tag = TestBaseUtil.createTag(); tag.setLights(Arrays.asList(TestBaseUtil.createLight())); tagRequest.setTag(tag); response = getTagBCF().insertTag(tagRequest); assertTrue(response.isOperationSuccess()); assertEquals(0, response.getMessageInfoList().size()); // Error situation resetMocksToTagArea(); setSituation(getTagBCF(), SituationsEnum.ERROR, ITagBCL.class); tagRequest = TestBaseUtil.createTagRequest(); tag = TestBaseUtil.createTag(); tag.setLights(Arrays.asList(TestBaseUtil.createLight())); tagRequest.setTag(tag); response = getTagBCF().insertTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages(response, ERROR_CODE); // Exception situation resetMocksToTagArea(); setSituation(getTagBCF(), SituationsEnum.EXCEPTION, ITagBCL.class); tagRequest = TestBaseUtil.createTagRequest(); tag = TestBaseUtil.createTag(); tag.setLights(Arrays.asList(TestBaseUtil.createLight())); tagRequest.setTag(tag); response = getTagBCF().insertTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages(response, DEFAULT_TAG_BCF_EXCEPTION_MSG); // Error situation - Name length invalid tagRequest = TestBaseUtil.createTagRequest(); tag = TestBaseUtil.createTag(); tag.setName(StringUtils.repeat("n", ONE_HUNDRED_ONE)); tagRequest.setTag(tag); response = getTagBCF().insertTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages(response, SENSUS_MLC_VALIDATOR_LENGTH_INVALID); }
/** Test update auto group tag. */ @Test public void testUpdateAutoGroupTag() { // Validation situation TagRequest tagRequest = new TagRequest(new UserContext(1)); Tag tag = new Tag(); tagRequest.setTag(tag); TagResponse response = getTagBCF().updateAutoGroupTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages( response, SENSUS_MLC_VALIDATOR_ID_REQUIRED, SENSUS_MLC_VALIDATOR_REQUIRED, SENSUS_MLC_VALIDATOR_ID_REQUIRED); // Success situation tagRequest = TestBaseUtil.createTagRequest(); tag = TestBaseUtil.createTag(); tag.setAutoGroup(true); tagRequest.setTag(tag); tagRequest.setIncludeLightsToGroup(true); response = getTagBCF().updateAutoGroupTag(tagRequest); assertTrue(response.isOperationSuccess()); assertEquals(0, response.getMessageInfoList().size()); // Error situation resetMocksToTagArea(); setSituation(getTagBCF(), SituationsEnum.ERROR, ITagBCL.class, UPDATE_AUTO_GROUP_TAG); tagRequest = TestBaseUtil.createTagRequest(); tag = TestBaseUtil.createTag(); tag.setAutoGroup(true); tagRequest.setTag(tag); tagRequest.setIncludeLightsToGroup(true); response = getTagBCF().updateAutoGroupTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages(response, ERROR_CODE); // Error situation tagRequest = TestBaseUtil.createTagRequest(); tag = TestBaseUtil.createTag(); tag.setId(null); tagRequest.setTag(tag); tagRequest.setIncludeLightsToGroup(true); response = getTagBCF().updateAutoGroupTag(tagRequest); assertFalse(response.isOperationSuccess()); // Error situation tagRequest = TestBaseUtil.createTagRequest(); response = getTagBCF().updateAutoGroupTag(tagRequest); assertFalse(response.isOperationSuccess()); // Exception situation resetMocksToTagArea(); setSituation(getTagBCF(), SituationsEnum.EXCEPTION, ITagBCL.class, UPDATE_AUTO_GROUP_TAG); tagRequest = TestBaseUtil.createTagRequest(); tag = TestBaseUtil.createTag(); tag.setAutoGroup(true); tagRequest.setTag(tag); tagRequest.setIncludeLightsToGroup(true); response = getTagBCF().updateAutoGroupTag(tagRequest); assertFalse(response.isOperationSuccess()); assertMessages(response, DEFAULT_TAG_BCF_EXCEPTION_MSG); }