// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/exceptions/InternetConnectionException.java
// public class InternetConnectionException extends Exception {
//     public InternetConnectionException(String detailMessage) {
//         super(detailMessage);
//     }
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/executors/Interactor.java
// public interface Interactor {
//     void run() throws InternetConnectionException;
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
//     void run(Interactor interactor) throws InternetConnectionException;
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/executors/MainThread.java
// public interface MainThread {
//     void post(final Runnable runnable);
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/models/SearchJSONResults.java
// public class SearchJSONResults {
// 
//     @SerializedName("Search")
//     private List<SearchJSONEntity> searchList;
// 
//     public List<SearchJSONEntity> getSearchList() {
//         return searchList;
//     }
// 
//     public class SearchJSONEntity {
//         @SerializedName("Title")
//         private String title;
//         @SerializedName("Year")
//         private String year;
//         @SerializedName("Type")
//         private String type;
//         private String imdbID;
//         @SerializedName("Poster")
//         private String imageUrl;
// 
//         public String getTitle() {
//             return title;
//         }
// 
//         public String getYear() {
//             return year;
//         }
// 
//         public String getType() {
//             return type;
//         }
// 
//         public String getImdbID() {
//             return imdbID;
//         }
// 
//         public String getImageUrl() {
//             return imageUrl;
//         }
//     }
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/repository/MoviesFinderRepository.java
// public interface MoviesFinderRepository<L, M> {
// 
//     /**
//      * to get the List of
//      **/
//     L getMoviesList(String q) throws InternetConnectionException;
// 
//     /**
//      * to get Movie detail
//      **/
//     M getMovie(String id) throws InternetConnectionException;
// }


import com.raulh82vlc.MoviesFinder.domain.exceptions.InternetConnectionException;
import com.raulh82vlc.MoviesFinder.domain.executors.Interactor;
import com.raulh82vlc.MoviesFinder.domain.executors.InteractorExecutor;
import com.raulh82vlc.MoviesFinder.domain.executors.MainThread;
import com.raulh82vlc.MoviesFinder.domain.models.SearchJSONResults;
import com.raulh82vlc.MoviesFinder.domain.repository.MoviesFinderRepository;
import javax.inject.Inject;
        try {
            SearchJSONResults moviesList = (SearchJSONResults) repository.getMoviesList(query);
            if (moviesList != null) {
                notifySuccessfullyLoaded(moviesList);
            } else {
                notifyError(errorMessage);
            }
        } catch (InternetConnectionException e) {
            notifyError(e.getMessage());
            throw new InternetConnectionException(e.getMessage());
        }
    }

    /**
     * <p>Notifies to the UI (main) thread the result of the request,
     * and sends a callback with a list</p>
     */
    private void notifySuccessfullyLoaded(final SearchJSONResults moviesList) {
        mainThread.post(new Runnable() {
            @Override
            public void run() {
                callback.onGetMoviesListOK(moviesList);
            }
        });
    }

    /**
     * <p>Notifies to the UI (main) thread that an error happened</p>
     */
    private void notifyError(final String error) {
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/exceptions/InternetConnectionException.java
// public class InternetConnectionException extends Exception {
//     public InternetConnectionException(String detailMessage) {
//         super(detailMessage);
//     }
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/executors/Interactor.java
// public interface Interactor {
//     void run() throws InternetConnectionException;
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/executors/InteractorExecutor.java
// public interface InteractorExecutor {
//     void run(Interactor interactor) throws InternetConnectionException;
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/executors/MainThread.java
// public interface MainThread {
//     void post(final Runnable runnable);
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/models/SearchJSONResults.java
// public class SearchJSONResults {
// 
//     @SerializedName("Search")
//     private List<SearchJSONEntity> searchList;
// 
//     public List<SearchJSONEntity> getSearchList() {
//         return searchList;
//     }
// 
//     public class SearchJSONEntity {
//         @SerializedName("Title")
//         private String title;
//         @SerializedName("Year")
//         private String year;
//         @SerializedName("Type")
//         private String type;
//         private String imdbID;
//         @SerializedName("Poster")
//         private String imageUrl;
// 
//         public String getTitle() {
//             return title;
//         }
// 
//         public String getYear() {
//             return year;
//         }
// 
//         public String getType() {
//             return type;
//         }
// 
//         public String getImdbID() {
//             return imdbID;
//         }
// 
//         public String getImageUrl() {
//             return imageUrl;
//         }
//     }
// }
// 
// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/repository/MoviesFinderRepository.java
// public interface MoviesFinderRepository<L, M> {
// 
//     /**
//      * to get the List of
//      **/
//     L getMoviesList(String q) throws InternetConnectionException;
// 
//     /**
//      * to get Movie detail
//      **/
//     M getMovie(String id) throws InternetConnectionException;
// }


// Path: domain/src/main/java/com/raulh82vlc/MoviesFinder/domain/interactors/GetMoviesListInteractorImpl.java
import com.raulh82vlc.MoviesFinder.domain.exceptions.InternetConnectionException;
import com.raulh82vlc.MoviesFinder.domain.executors.Interactor;
import com.raulh82vlc.MoviesFinder.domain.executors.InteractorExecutor;
import com.raulh82vlc.MoviesFinder.domain.executors.MainThread;
import com.raulh82vlc.MoviesFinder.domain.models.SearchJSONResults;
import com.raulh82vlc.MoviesFinder.domain.repository.MoviesFinderRepository;
import javax.inject.Inject;

        try {
            SearchJSONResults moviesList = (SearchJSONResults) repository.getMoviesList(query);
            if (moviesList != null) {
                notifySuccessfullyLoaded(moviesList);
            } else {
                notifyError(errorMessage);
            }
        } catch (InternetConnectionException e) {
            notifyError(e.getMessage());
            throw new InternetConnectionException(e.getMessage());
        }
    }

    /**
     * <p>Notifies to the UI (main) thread the result of the request,
     * and sends a callback with a list</p>
     */
    private void notifySuccessfullyLoaded(final SearchJSONResults moviesList) {
        mainThread.post(new Runnable() {
            @Override
            public void run() {
                callback.onGetMoviesListOK(moviesList);
            }
        });
    }

    /**
     * <p>Notifies to the UI (main) thread that an error happened</p>
     */
    private void notifyError(final String error) {
        mainThread.post(new Runnable() {