func (cmd *MigrateApps) Execute(cliConnection api.Connection) error {
	cmd.MigrateAppsCommand.BeforeAll() //move me to the command

	apiClient, err := api.NewClient(cliConnection)
	if err != nil {
		return err
	}

	appRequestFactory := apiClient.HandleFiltersAndParameters(
		apiClient.Authorize(apiClient.NewGetAppsRequest),
	)

	appPaginatedRequester, err := api.NewPaginatedRequester(cliConnection, appRequestFactory)
	if err != nil {
		return err
	}

	apps, err := cmd.AppsGetterFunc(
		models.ApplicationsParser{},
		appPaginatedRequester,
	)
	if err != nil {
		return err
	}

	spaceRequestFactory := apiClient.HandleFiltersAndParameters(
		apiClient.Authorize(apiClient.NewGetSpacesRequest),
	)

	spacePaginatedRequester, err := api.NewPaginatedRequester(cliConnection, spaceRequestFactory)
	if err != nil {
		return err
	}

	spaces, err := thingdoer.Spaces(
		models.SpacesParser{},
		spacePaginatedRequester,
	)
	if err != nil {
		return err
	}

	spaceMap := make(map[string]models.Space)
	for _, space := range spaces {
		spaceMap[space.Guid] = space
	}

	warnings, errors := cmd.migrateApps(cliConnection, apps, spaceMap, cmd.MaxInFlight)
	cmd.MigrateAppsCommand.AfterAll(len(apps), warnings, errors)

	return nil
}
func ListApps(cliConnection api.Connection, appsGetterFunc thingdoer.AppsGetterFunc, listAppsCommand *ui.ListAppsCommand) error {
	listAppsCommand.BeforeAll()

	appsParser := models.ApplicationsParser{}
	spacesParser := models.SpacesParser{}

	apiClient, err := api.NewClient(cliConnection)
	if err != nil {
		return err
	}

	appRequestFactory := apiClient.HandleFiltersAndParameters(
		apiClient.Authorize(apiClient.NewGetAppsRequest),
	)

	appPaginatedRequester, err := api.NewPaginatedRequester(cliConnection, appRequestFactory)
	if err != nil {
		return err
	}

	apps, err := appsGetterFunc(
		appsParser,
		appPaginatedRequester,
	)
	if err != nil {
		return err
	}

	spaceRequestFactory := apiClient.HandleFiltersAndParameters(
		apiClient.Authorize(apiClient.NewGetSpacesRequest),
	)
	spacesPaginatedRequester, err := api.NewPaginatedRequester(cliConnection, spaceRequestFactory)
	if err != nil {
		return err
	}

	spaces, err := thingdoer.Spaces(
		spacesParser,
		spacesPaginatedRequester,
	)
	if err != nil {
		return err
	}

	spaceMap := make(map[string]models.Space)
	for _, space := range spaces {
		spaceMap[space.Guid] = space
	}

	var appPrinters []ui.ApplicationPrinter
	for _, a := range apps {
		appPrinters = append(appPrinters, &displayhelpers.AppPrinter{
			App:    a,
			Spaces: spaceMap,
		})
	}

	listAppsCommand.AfterAll(appPrinters)

	return nil
}
var _ = Describe("Spaces", func() {
	var (
		fakePaginatedRequester *thingdoerfakes.FakePaginatedRequester
		fakeSpacesParser       *thingdoerfakes.FakeSpacesParser
		spaces                 models.Spaces
		err                    error
	)

	BeforeEach(func() {
		fakePaginatedRequester = new(thingdoerfakes.FakePaginatedRequester)
		fakeSpacesParser = new(thingdoerfakes.FakeSpacesParser)
	})

	JustBeforeEach(func() {
		spaces, err = thingdoer.Spaces(fakeSpacesParser, fakePaginatedRequester)
	})

	It("should create a request inline-relations-depth of 1", func() {
		expectedParams := map[string]interface{}{
			"inline-relations-depth": 1,
		}

		Expect(fakePaginatedRequester.DoCallCount()).To(Equal(1))
		_, params := fakePaginatedRequester.DoArgsForCall(0)
		Expect(params).To(Equal(expectedParams))
	})

	Context("when the paginated requester fails", func() {
		var requestError error