CrudEventBuilder { public static String createSubject(EntityInfo entity, String action) { return createSubject(entity.getModule(), entity.getNamespace(), entity.getEntityName(), action); } private  CrudEventBuilder(); static Map<String, Object> buildEventParams(String module, String namespace, String entity, String entityClassName, Long id); static String createSubject(EntityInfo entity, String action); static String createSubject(String module, String namespace, String entity, CrudEventType action); static String createSubject(String module, String namespace, String entity, String action); static void setEntityData(Map<String, Object> params, String module, String namespace, String entityName,
                                     String entityClassName);  }
@Test public void shouldReturnValidSubject() { String subject = CrudEventBuilder.createSubject(MODULE, NAMESPACE, ENTITY, CREATE); String expected = BASE_SUBJECT + MODULE + "." + NAMESPACE + "." + ENTITY + "." + CREATE; assertThat(subject, equalTo(expected)); }
@Test public void shouldReturnValidSubjectWithoutModuleAndNamespace() { String subject = CrudEventBuilder.createSubject(null, null, ENTITY, CREATE); String expected = BASE_SUBJECT + ENTITY + "." + CREATE; assertThat(subject, equalTo(expected)); }
@Test public void shouldReturnValidSubjectWithoutNamespace() { String subject = CrudEventBuilder.createSubject(MODULE, null, ENTITY, CREATE); String expected = BASE_SUBJECT + MODULE + "." + ENTITY + "." + CREATE; assertThat(subject, equalTo(expected)); }