@Test public void executeTest() { assertEquals(1, getEntityManager().createQuery("FROM DomainGroup WHERE id = 2").getResultList().size()); assertEquals(1, getEntityManager().createQuery("FROM StreamScope WHERE id = 875").getResultList().size()); assertEquals(1, getEntityManager().createQuery( "FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type") .setParameter("uniqueKey", "group2").setParameter("type", ScopeType.GROUP).getResultList().size()); DeleteGroupResponse response = sut.execute(groupId); getEntityManager().flush(); getEntityManager().clear(); assertEquals(2, response.getGroupId().longValue()); assertEquals("group2", response.getGroupShortName()); assertEquals(groupStreamScopeId, response.getStreamScopeId().longValue()); assertEquals(0, getEntityManager().createQuery("FROM DomainGroup WHERE id = 2").getResultList().size()); assertEquals(0, getEntityManager().createQuery("FROM StreamScope WHERE id = 875").getResultList().size()); assertEquals(0, getEntityManager().createQuery( "FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type") .setParameter("uniqueKey", "group2").setParameter("type", ScopeType.GROUP).getResultList().size()); }
@Override public DeleteGroupResponse execute(final Long inRequest) { DomainGroup group = groupMapper.execute(new FindByIdRequest("DomainGroup", inRequest)); Long groupId = group.getId(); DeleteGroupResponse response = new DeleteGroupResponse(groupId, group.getShortName(), new Long(group .getStreamScope().getId())); getEntityManager().createQuery( "DELETE FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type") .setParameter("uniqueKey", group.getUniqueId()).setParameter("type", ScopeType.GROUP).executeUpdate(); getEntityManager().remove(group); return response; }
DeleteGroup extends BaseArgDomainMapper<Long, DeleteGroupResponse> { @Override public DeleteGroupResponse execute(final Long inRequest) { DomainGroup group = groupMapper.execute(new FindByIdRequest("DomainGroup", inRequest)); Long groupId = group.getId(); DeleteGroupResponse response = new DeleteGroupResponse(groupId, group.getShortName(), new Long(group .getStreamScope().getId())); getEntityManager().createQuery( "DELETE FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type") .setParameter("uniqueKey", group.getUniqueId()).setParameter("type", ScopeType.GROUP).executeUpdate(); getEntityManager().remove(group); return response; } }
DeleteGroup extends BaseArgDomainMapper<Long, DeleteGroupResponse> { @Override public DeleteGroupResponse execute(final Long inRequest) { DomainGroup group = groupMapper.execute(new FindByIdRequest("DomainGroup", inRequest)); Long groupId = group.getId(); DeleteGroupResponse response = new DeleteGroupResponse(groupId, group.getShortName(), new Long(group .getStreamScope().getId())); getEntityManager().createQuery( "DELETE FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type") .setParameter("uniqueKey", group.getUniqueId()).setParameter("type", ScopeType.GROUP).executeUpdate(); getEntityManager().remove(group); return response; } DeleteGroup(final FindByIdMapper<DomainGroup> inGroupMapper); }
DeleteGroup extends BaseArgDomainMapper<Long, DeleteGroupResponse> { @Override public DeleteGroupResponse execute(final Long inRequest) { DomainGroup group = groupMapper.execute(new FindByIdRequest("DomainGroup", inRequest)); Long groupId = group.getId(); DeleteGroupResponse response = new DeleteGroupResponse(groupId, group.getShortName(), new Long(group .getStreamScope().getId())); getEntityManager().createQuery( "DELETE FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type") .setParameter("uniqueKey", group.getUniqueId()).setParameter("type", ScopeType.GROUP).executeUpdate(); getEntityManager().remove(group); return response; } DeleteGroup(final FindByIdMapper<DomainGroup> inGroupMapper); @Override DeleteGroupResponse execute(final Long inRequest); }
DeleteGroup extends BaseArgDomainMapper<Long, DeleteGroupResponse> { @Override public DeleteGroupResponse execute(final Long inRequest) { DomainGroup group = groupMapper.execute(new FindByIdRequest("DomainGroup", inRequest)); Long groupId = group.getId(); DeleteGroupResponse response = new DeleteGroupResponse(groupId, group.getShortName(), new Long(group .getStreamScope().getId())); getEntityManager().createQuery( "DELETE FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type") .setParameter("uniqueKey", group.getUniqueId()).setParameter("type", ScopeType.GROUP).executeUpdate(); getEntityManager().remove(group); return response; } DeleteGroup(final FindByIdMapper<DomainGroup> inGroupMapper); @Override DeleteGroupResponse execute(final Long inRequest);  }