func NewAppsGetterFunc(
	cliConnection api.Connection,
	orgName string,
	spaceName string,
	runtime ui.Runtime,
) (thingdoer.AppsGetterFunc, error) {
	diegoAppsCommand := thingdoer.AppsGetter{}

	if orgName != "" {
		org, err := cliConnection.GetOrg(orgName)
		if err != nil || org.Guid == "" {
			return nil, OrgNotFoundErr{OrganizationName: orgName}
		}
		diegoAppsCommand.OrganizationGuid = org.Guid
	} else if spaceName != "" {
		space, err := cliConnection.GetSpace(spaceName)
		if err != nil || space.Guid == "" {
			return nil, SpaceNotFoundErr{SpaceName: spaceName}
		}
		diegoAppsCommand.SpaceGuid = space.Guid
	}

	var appsGetterFunc = diegoAppsCommand.DiegoApps
	if runtime == ui.DEA {
		appsGetterFunc = diegoAppsCommand.DeaApps
	}

	return appsGetterFunc, nil
}
import (
	"errors"

	"github.com/cloudfoundry-incubator/diego-enabler/api"
	"github.com/cloudfoundry-incubator/diego-enabler/models"
	"github.com/cloudfoundry-incubator/diego-enabler/thingdoer"
	"github.com/cloudfoundry-incubator/diego-enabler/thingdoer/thingdoerfakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("DeaApps", func() {
	var (
		fakePaginatedRequester *thingdoerfakes.FakePaginatedRequester
		fakeApplicationsParser *thingdoerfakes.FakeApplicationsParser
		apps                   models.Applications

		command thingdoer.AppsGetter
		err     error
	)

	BeforeEach(func() {
		fakePaginatedRequester = new(thingdoerfakes.FakePaginatedRequester)
		fakeApplicationsParser = new(thingdoerfakes.FakeApplicationsParser)
		command = thingdoer.AppsGetter{}
	})

	JustBeforeEach(func() {
		apps, err = command.DeaApps(fakeApplicationsParser, fakePaginatedRequester)
	})

	It("should create a request with diego filter set to false", func() {