Package cleancoderscom.tests.fixtures

Source Code of cleancoderscom.tests.fixtures.OfCodeCasts

package cleancoderscom.tests.fixtures;

import cleancoderscom.Context;
import cleancoderscom.PresentCodecastUseCase;
import cleancoderscom.PresentableCodecast;
import cleancoderscom.User;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

//OrderedQuery
public class OfCodeCasts {
  private List<Object> list(Object... objects) {
    return Arrays.asList(objects);
  }

  public List<Object> query() {
    User loggedInUser = Context.gateKeeper.getLoggedInUser();
    PresentCodecastUseCase useCase = new PresentCodecastUseCase();
    List<PresentableCodecast> presentableCodecasts = useCase.presentCodecasts(loggedInUser);
    List<Object> queryResponse = new ArrayList<Object>();
    for (PresentableCodecast pcc : presentableCodecasts)
      queryResponse.add(makeRow(pcc));
    return queryResponse;

  }

  private List<Object> makeRow(PresentableCodecast pc) {
    return list(
      new Object[]{list("title", pc.title),
        list("publication date", pc.publicationDate),
        list("picture", pc.title),
        list("description", pc.title),
        list("viewable", pc.isViewable ? "+" : "-"),
        list("downloadable", pc.isDownloadable ? "+" : "-")}
    );
  }

}
TOP

Related Classes of cleancoderscom.tests.fixtures.OfCodeCasts

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.