@Test public void testGetNaturalKeyFields() throws NoNaturalKeysDefinedException { Entity e = setup(); Map<String, Boolean> naturalKeyFields = naturalKeyExtractor.getNaturalKeyFields(e); Assert.assertEquals(1, naturalKeyFields.size()); Assert.assertEquals("someField", naturalKeyFields.entrySet().iterator().next().getKey()); Mockito.verify(entitySchemaRegistry, Mockito.times(1)).getSchema(Mockito.anyString()); }
@Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; }
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; } }
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; }  }
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; }  @Override Map<String, String> getNaturalKeys(Entity entity); @Override Map<String, Boolean> getNaturalKeyFields(Entity entity); @Override NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity); String getCollectionName(Entity entity); }
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; }  @Override Map<String, String> getNaturalKeys(Entity entity); @Override Map<String, Boolean> getNaturalKeyFields(Entity entity); @Override NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity); String getCollectionName(Entity entity);  }