### Question:
MetadataService implements IMetadataService { @Override public <T> AgEntity<T> getAgEntity(Class<T> type) { if (type == null) { throw new NullPointerException("Null type"); } AgEntity<T> e = dataMap.getEntity(type); if (e == null) { throw new AgException(Status.BAD_REQUEST, "Invalid entity: " + type.getName()); } return e; } MetadataService(@Inject List<AgEntityCompiler> entityCompilers); @Override AgEntity<T> getAgEntity(Class<T> type); @Override AgEntity<T> getAgEntityByType(Type entityType);  }### Answer:
@Test public void testGetAgEntity_Relationships() { AgEntity<Ts> ts = metadata.getAgEntity(Ts.class); assertNotNull(ts); assertEquals("Ts", ts.getName()); assertSame(Ts.class, ts.getType()); assertEquals("Ts", ts.getName()); assertNotNull(ts.getAttribute("m")); assertNotNull(ts.getAttribute("n")); assertNotNull(ts.getRelationship("rtrs")); assertEquals(1, ts.getRelationships().size()); }
@Test public void testGetAgEntity_NoRelationships() { AgEntity<Tr> tr = metadata.getAgEntity(Tr.class); assertNotNull(tr); assertEquals("Tr", tr.getName()); assertSame(Tr.class, tr.getType()); assertEquals("Tr", tr.getName()); assertNotNull(tr.getAttribute("a")); assertNotNull(tr.getAttribute("b")); assertEquals(0, tr.getRelationships().size()); }