### Question:
VFModuleRestHandler extends AbstractRestHandler { public Recipe findVfModuleRecipe(String modelCustomizationId, String modelType, String action) throws NoRecipeException { VnfComponentsRecipe recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( modelCustomizationId, modelType, action); if (recipe == null) { recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( "GR-API-DEFAULT", modelType, action); } if (recipe == null) { throw new NoRecipeException(String.format( "Unable to locate custom or default recipe for ModelType: %s , Action: %s, CustomizationId: %s", modelType, action, modelCustomizationId)); } return recipe; }  InfraActiveRequests mapInfraActiveRequestForDelete(String requestId, String vfModuleId,
            String serviceInstanceId, String vnfId, String requestorId, String source, String requestURL); InfraActiveRequests createInfraActiveRequestForDelete(String requestId, String vfModuleId,
            String serviceInstanceId, String vnfId, String requestorId, String source, String requestURL); RequestClientParameter buildRequestParams(ServiceInstancesRequest request, String requestURI,
            String requestId, String serviceInstanceId, String vnfId, String vfModuleId); void saveInstanceName(ServiceInstancesRequest request, InfraActiveRequests currentRequest); void checkDuplicateRequest(String serviceInstanceId, String vnfInstanceId, String vfmoduleInstanceId,
            String instanceName, String requestId); Recipe findVfModuleRecipe(String modelCustomizationId, String modelType, String action);  }### Answer:
@Test public void test_find_vf_module_recipe() throws MalformedURLException, NoRecipeException { VnfComponentsRecipe expected = new VnfComponentsRecipe(); expected.setAction("createInstance"); doReturn(expected).when(catalogDbClient) .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); assertThat(actual, sameBeanAs(expected)); Mockito.verify(catalogDbClient, Mockito.times(1)) .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); }
@Test public void test_find_vf_module_recipe_default_recipe() throws MalformedURLException, NoRecipeException { VnfComponentsRecipe expected = new VnfComponentsRecipe(); expected.setAction("createInstance"); doReturn(null).when(catalogDbClient).getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( "testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); doReturn(expected).when(catalogDbClient) .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("GR-API-DEFAULT", ModelType.vfModule.toString(), Action.createInstance.toString()); Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); assertThat(actual, sameBeanAs(expected)); Mockito.verify(catalogDbClient, Mockito.times(1)) .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); }
@Test public void test_find_vf_module_recipe_not_found() throws MalformedURLException, NoRecipeException { VnfComponentsRecipe expected = new VnfComponentsRecipe(); expected.setAction("createInstance"); exceptionRule.expect(NoRecipeException.class); exceptionRule.expectMessage( "Unable to locate custom or default recipe for ModelType: vfModule , Action: createInstance, CustomizationId: testModelId"); restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString()); }