### Question:
FactTypeHelper { public void assertFactTypesToBindExist(List<MetaFactBindingDefinition> bindingDefinitions, String propertyName) throws InvalidArgumentException { if (CollectionUtils.isEmpty(bindingDefinitions)) return; InvalidArgumentException ex = new InvalidArgumentException(); for (int i = 0; i < bindingDefinitions.size(); i++) { UUID factTypeID = bindingDefinitions.get(i).getFactType(); if (factManager.getFactType(factTypeID) == null) { ex.addValidationError(String.format("FactType with id = %s does not exist.", factTypeID), "fact.type.not.exist", String.format("%s[%d].factType", propertyName, i), factTypeID.toString()); } } if (ex.hasErrors()) throw ex; } @Inject  FactTypeHelper(FactManager factManager, ObjectManager objectManager); void assertFactTypeNotExists(String name); void assertObjectTypesToBindExist(List<FactObjectBindingDefinition> bindingDefinitions, String propertyName); void assertFactTypesToBindExist(List<MetaFactBindingDefinition> bindingDefinitions, String propertyName); Set<FactTypeEntity.FactObjectBindingDefinition> convertFactObjectBindingDefinitions(List<FactObjectBindingDefinition> bindingDefinitions); Set<FactTypeEntity.MetaFactBindingDefinition> convertMetaFactBindingDefinitions(List<MetaFactBindingDefinition> bindingDefinitions);  }### Answer:
@Test public void testAssertFactTypesToBindExistWithoutBindings() throws Exception { helper.assertFactTypesToBindExist(null, "property"); helper.assertFactTypesToBindExist(ListUtils.list(), "property"); verifyZeroInteractions(factManager); }
@Test public void testAssertFactTypesToBindSuccess() throws Exception { UUID factType = UUID.randomUUID(); List<MetaFactBindingDefinition> definitions = ListUtils.list(new MetaFactBindingDefinition() .setFactType(factType) ); when(factManager.getFactType(isA(UUID.class))).thenReturn(new FactTypeEntity()); helper.assertFactTypesToBindExist(definitions, "property"); verify(factManager).getFactType(factType); }
@Test public void testAssertFactTypesToBindExistFailure() { UUID factType = UUID.randomUUID(); List<MetaFactBindingDefinition> definitions = ListUtils.list(new MetaFactBindingDefinition() .setFactType(factType) ); try { helper.assertFactTypesToBindExist(definitions, "property"); fail(); } catch (InvalidArgumentException ignored) { } verify(factManager).getFactType(factType); }