repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/internal/di/ApiModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardRetrofitApi.java // public class DashboardRetrofitApi extends AbsRetrofitApi implements DashboardApi { // private final DashboardEndpoint endpoint; // private final ImageResponseMapper mapper; // // @Inject // public DashboardRetrofitApi(DashboardEndpoint endpoint, ImageResponseMapper mapper) { // this.endpoint = endpoint; // this.mapper = mapper; // } // // @Override // public List<ImageResponse> getDashboard() { // List<ImageResponse> result = new ArrayList<>(); // try { // final Call<DashboardListEndpointResponse> apiCaller = endpoint.getDashboard(API_KEY); // final Response<DashboardListEndpointResponse> response = apiCaller.execute(); // final DashboardListEndpointResponse images = response.body(); // result = mapper.map(images); // } catch (IOException e) { // throw new RuntimeException(e); // } // return result; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java // public class ImageResponseMapperImpl implements ImageResponseMapper { // private final ImageUriTransformer imageUriTransformer; // // @Inject // public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { // this.imageUriTransformer = imageUriTransformer; // } // // @Override // public List<ImageResponse> map(DashboardListEndpointResponse source) { // List<ImageResponse> result = new ArrayList<>(source.data.size()); // for (int location = 0; location < source.data.size(); location++) { // final ImageResponse image = map(source.data.get(location)); // result.add(image); // } // return result; // } // // @Override // public List<ImageEntity> map(List<ImageResponse> source) { // List<ImageEntity> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageEntity image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageEntity map(ImageResponse source) { // return new ImageEntity.Builder() // .setUrl(source.getUrl()) // .build(); // } // // @Override // public ImageResponse map(DashboardEndpointResponse source) { // return new ImageResponse.Builder() // .setUrl(Uri.parse(imageUriTransformer.transform(source.id))) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.DashboardRetrofitApi; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.api.model.ImageResponseMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.internal.di; @Module public class ApiModule { @Provides
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardRetrofitApi.java // public class DashboardRetrofitApi extends AbsRetrofitApi implements DashboardApi { // private final DashboardEndpoint endpoint; // private final ImageResponseMapper mapper; // // @Inject // public DashboardRetrofitApi(DashboardEndpoint endpoint, ImageResponseMapper mapper) { // this.endpoint = endpoint; // this.mapper = mapper; // } // // @Override // public List<ImageResponse> getDashboard() { // List<ImageResponse> result = new ArrayList<>(); // try { // final Call<DashboardListEndpointResponse> apiCaller = endpoint.getDashboard(API_KEY); // final Response<DashboardListEndpointResponse> response = apiCaller.execute(); // final DashboardListEndpointResponse images = response.body(); // result = mapper.map(images); // } catch (IOException e) { // throw new RuntimeException(e); // } // return result; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java // public class ImageResponseMapperImpl implements ImageResponseMapper { // private final ImageUriTransformer imageUriTransformer; // // @Inject // public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { // this.imageUriTransformer = imageUriTransformer; // } // // @Override // public List<ImageResponse> map(DashboardListEndpointResponse source) { // List<ImageResponse> result = new ArrayList<>(source.data.size()); // for (int location = 0; location < source.data.size(); location++) { // final ImageResponse image = map(source.data.get(location)); // result.add(image); // } // return result; // } // // @Override // public List<ImageEntity> map(List<ImageResponse> source) { // List<ImageEntity> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageEntity image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageEntity map(ImageResponse source) { // return new ImageEntity.Builder() // .setUrl(source.getUrl()) // .build(); // } // // @Override // public ImageResponse map(DashboardEndpointResponse source) { // return new ImageResponse.Builder() // .setUrl(Uri.parse(imageUriTransformer.transform(source.id))) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/internal/di/ApiModule.java import dagger.Provides; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.DashboardRetrofitApi; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.api.model.ImageResponseMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.internal.di; @Module public class ApiModule { @Provides
DashboardApi provideDashboardApi(DashboardRetrofitApi api) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/internal/di/ApiModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardRetrofitApi.java // public class DashboardRetrofitApi extends AbsRetrofitApi implements DashboardApi { // private final DashboardEndpoint endpoint; // private final ImageResponseMapper mapper; // // @Inject // public DashboardRetrofitApi(DashboardEndpoint endpoint, ImageResponseMapper mapper) { // this.endpoint = endpoint; // this.mapper = mapper; // } // // @Override // public List<ImageResponse> getDashboard() { // List<ImageResponse> result = new ArrayList<>(); // try { // final Call<DashboardListEndpointResponse> apiCaller = endpoint.getDashboard(API_KEY); // final Response<DashboardListEndpointResponse> response = apiCaller.execute(); // final DashboardListEndpointResponse images = response.body(); // result = mapper.map(images); // } catch (IOException e) { // throw new RuntimeException(e); // } // return result; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java // public class ImageResponseMapperImpl implements ImageResponseMapper { // private final ImageUriTransformer imageUriTransformer; // // @Inject // public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { // this.imageUriTransformer = imageUriTransformer; // } // // @Override // public List<ImageResponse> map(DashboardListEndpointResponse source) { // List<ImageResponse> result = new ArrayList<>(source.data.size()); // for (int location = 0; location < source.data.size(); location++) { // final ImageResponse image = map(source.data.get(location)); // result.add(image); // } // return result; // } // // @Override // public List<ImageEntity> map(List<ImageResponse> source) { // List<ImageEntity> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageEntity image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageEntity map(ImageResponse source) { // return new ImageEntity.Builder() // .setUrl(source.getUrl()) // .build(); // } // // @Override // public ImageResponse map(DashboardEndpointResponse source) { // return new ImageResponse.Builder() // .setUrl(Uri.parse(imageUriTransformer.transform(source.id))) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.DashboardRetrofitApi; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.api.model.ImageResponseMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.internal.di; @Module public class ApiModule { @Provides
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardRetrofitApi.java // public class DashboardRetrofitApi extends AbsRetrofitApi implements DashboardApi { // private final DashboardEndpoint endpoint; // private final ImageResponseMapper mapper; // // @Inject // public DashboardRetrofitApi(DashboardEndpoint endpoint, ImageResponseMapper mapper) { // this.endpoint = endpoint; // this.mapper = mapper; // } // // @Override // public List<ImageResponse> getDashboard() { // List<ImageResponse> result = new ArrayList<>(); // try { // final Call<DashboardListEndpointResponse> apiCaller = endpoint.getDashboard(API_KEY); // final Response<DashboardListEndpointResponse> response = apiCaller.execute(); // final DashboardListEndpointResponse images = response.body(); // result = mapper.map(images); // } catch (IOException e) { // throw new RuntimeException(e); // } // return result; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java // public class ImageResponseMapperImpl implements ImageResponseMapper { // private final ImageUriTransformer imageUriTransformer; // // @Inject // public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { // this.imageUriTransformer = imageUriTransformer; // } // // @Override // public List<ImageResponse> map(DashboardListEndpointResponse source) { // List<ImageResponse> result = new ArrayList<>(source.data.size()); // for (int location = 0; location < source.data.size(); location++) { // final ImageResponse image = map(source.data.get(location)); // result.add(image); // } // return result; // } // // @Override // public List<ImageEntity> map(List<ImageResponse> source) { // List<ImageEntity> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageEntity image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageEntity map(ImageResponse source) { // return new ImageEntity.Builder() // .setUrl(source.getUrl()) // .build(); // } // // @Override // public ImageResponse map(DashboardEndpointResponse source) { // return new ImageResponse.Builder() // .setUrl(Uri.parse(imageUriTransformer.transform(source.id))) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/internal/di/ApiModule.java import dagger.Provides; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.DashboardRetrofitApi; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.api.model.ImageResponseMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.internal.di; @Module public class ApiModule { @Provides
DashboardApi provideDashboardApi(DashboardRetrofitApi api) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/internal/di/ApiModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardRetrofitApi.java // public class DashboardRetrofitApi extends AbsRetrofitApi implements DashboardApi { // private final DashboardEndpoint endpoint; // private final ImageResponseMapper mapper; // // @Inject // public DashboardRetrofitApi(DashboardEndpoint endpoint, ImageResponseMapper mapper) { // this.endpoint = endpoint; // this.mapper = mapper; // } // // @Override // public List<ImageResponse> getDashboard() { // List<ImageResponse> result = new ArrayList<>(); // try { // final Call<DashboardListEndpointResponse> apiCaller = endpoint.getDashboard(API_KEY); // final Response<DashboardListEndpointResponse> response = apiCaller.execute(); // final DashboardListEndpointResponse images = response.body(); // result = mapper.map(images); // } catch (IOException e) { // throw new RuntimeException(e); // } // return result; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java // public class ImageResponseMapperImpl implements ImageResponseMapper { // private final ImageUriTransformer imageUriTransformer; // // @Inject // public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { // this.imageUriTransformer = imageUriTransformer; // } // // @Override // public List<ImageResponse> map(DashboardListEndpointResponse source) { // List<ImageResponse> result = new ArrayList<>(source.data.size()); // for (int location = 0; location < source.data.size(); location++) { // final ImageResponse image = map(source.data.get(location)); // result.add(image); // } // return result; // } // // @Override // public List<ImageEntity> map(List<ImageResponse> source) { // List<ImageEntity> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageEntity image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageEntity map(ImageResponse source) { // return new ImageEntity.Builder() // .setUrl(source.getUrl()) // .build(); // } // // @Override // public ImageResponse map(DashboardEndpointResponse source) { // return new ImageResponse.Builder() // .setUrl(Uri.parse(imageUriTransformer.transform(source.id))) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.DashboardRetrofitApi; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.api.model.ImageResponseMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.internal.di; @Module public class ApiModule { @Provides DashboardApi provideDashboardApi(DashboardRetrofitApi api) { return api; } @Provides
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardRetrofitApi.java // public class DashboardRetrofitApi extends AbsRetrofitApi implements DashboardApi { // private final DashboardEndpoint endpoint; // private final ImageResponseMapper mapper; // // @Inject // public DashboardRetrofitApi(DashboardEndpoint endpoint, ImageResponseMapper mapper) { // this.endpoint = endpoint; // this.mapper = mapper; // } // // @Override // public List<ImageResponse> getDashboard() { // List<ImageResponse> result = new ArrayList<>(); // try { // final Call<DashboardListEndpointResponse> apiCaller = endpoint.getDashboard(API_KEY); // final Response<DashboardListEndpointResponse> response = apiCaller.execute(); // final DashboardListEndpointResponse images = response.body(); // result = mapper.map(images); // } catch (IOException e) { // throw new RuntimeException(e); // } // return result; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java // public class ImageResponseMapperImpl implements ImageResponseMapper { // private final ImageUriTransformer imageUriTransformer; // // @Inject // public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { // this.imageUriTransformer = imageUriTransformer; // } // // @Override // public List<ImageResponse> map(DashboardListEndpointResponse source) { // List<ImageResponse> result = new ArrayList<>(source.data.size()); // for (int location = 0; location < source.data.size(); location++) { // final ImageResponse image = map(source.data.get(location)); // result.add(image); // } // return result; // } // // @Override // public List<ImageEntity> map(List<ImageResponse> source) { // List<ImageEntity> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageEntity image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageEntity map(ImageResponse source) { // return new ImageEntity.Builder() // .setUrl(source.getUrl()) // .build(); // } // // @Override // public ImageResponse map(DashboardEndpointResponse source) { // return new ImageResponse.Builder() // .setUrl(Uri.parse(imageUriTransformer.transform(source.id))) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/internal/di/ApiModule.java import dagger.Provides; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.DashboardRetrofitApi; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.api.model.ImageResponseMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.internal.di; @Module public class ApiModule { @Provides DashboardApi provideDashboardApi(DashboardRetrofitApi api) { return api; } @Provides
ImageResponseMapper provideImageResponseMapper(ImageResponseMapperImpl mapper) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/internal/di/ApiModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardRetrofitApi.java // public class DashboardRetrofitApi extends AbsRetrofitApi implements DashboardApi { // private final DashboardEndpoint endpoint; // private final ImageResponseMapper mapper; // // @Inject // public DashboardRetrofitApi(DashboardEndpoint endpoint, ImageResponseMapper mapper) { // this.endpoint = endpoint; // this.mapper = mapper; // } // // @Override // public List<ImageResponse> getDashboard() { // List<ImageResponse> result = new ArrayList<>(); // try { // final Call<DashboardListEndpointResponse> apiCaller = endpoint.getDashboard(API_KEY); // final Response<DashboardListEndpointResponse> response = apiCaller.execute(); // final DashboardListEndpointResponse images = response.body(); // result = mapper.map(images); // } catch (IOException e) { // throw new RuntimeException(e); // } // return result; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java // public class ImageResponseMapperImpl implements ImageResponseMapper { // private final ImageUriTransformer imageUriTransformer; // // @Inject // public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { // this.imageUriTransformer = imageUriTransformer; // } // // @Override // public List<ImageResponse> map(DashboardListEndpointResponse source) { // List<ImageResponse> result = new ArrayList<>(source.data.size()); // for (int location = 0; location < source.data.size(); location++) { // final ImageResponse image = map(source.data.get(location)); // result.add(image); // } // return result; // } // // @Override // public List<ImageEntity> map(List<ImageResponse> source) { // List<ImageEntity> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageEntity image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageEntity map(ImageResponse source) { // return new ImageEntity.Builder() // .setUrl(source.getUrl()) // .build(); // } // // @Override // public ImageResponse map(DashboardEndpointResponse source) { // return new ImageResponse.Builder() // .setUrl(Uri.parse(imageUriTransformer.transform(source.id))) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.DashboardRetrofitApi; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.api.model.ImageResponseMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.internal.di; @Module public class ApiModule { @Provides DashboardApi provideDashboardApi(DashboardRetrofitApi api) { return api; } @Provides
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardRetrofitApi.java // public class DashboardRetrofitApi extends AbsRetrofitApi implements DashboardApi { // private final DashboardEndpoint endpoint; // private final ImageResponseMapper mapper; // // @Inject // public DashboardRetrofitApi(DashboardEndpoint endpoint, ImageResponseMapper mapper) { // this.endpoint = endpoint; // this.mapper = mapper; // } // // @Override // public List<ImageResponse> getDashboard() { // List<ImageResponse> result = new ArrayList<>(); // try { // final Call<DashboardListEndpointResponse> apiCaller = endpoint.getDashboard(API_KEY); // final Response<DashboardListEndpointResponse> response = apiCaller.execute(); // final DashboardListEndpointResponse images = response.body(); // result = mapper.map(images); // } catch (IOException e) { // throw new RuntimeException(e); // } // return result; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java // public class ImageResponseMapperImpl implements ImageResponseMapper { // private final ImageUriTransformer imageUriTransformer; // // @Inject // public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { // this.imageUriTransformer = imageUriTransformer; // } // // @Override // public List<ImageResponse> map(DashboardListEndpointResponse source) { // List<ImageResponse> result = new ArrayList<>(source.data.size()); // for (int location = 0; location < source.data.size(); location++) { // final ImageResponse image = map(source.data.get(location)); // result.add(image); // } // return result; // } // // @Override // public List<ImageEntity> map(List<ImageResponse> source) { // List<ImageEntity> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageEntity image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageEntity map(ImageResponse source) { // return new ImageEntity.Builder() // .setUrl(source.getUrl()) // .build(); // } // // @Override // public ImageResponse map(DashboardEndpointResponse source) { // return new ImageResponse.Builder() // .setUrl(Uri.parse(imageUriTransformer.transform(source.id))) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/internal/di/ApiModule.java import dagger.Provides; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.DashboardRetrofitApi; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.api.model.ImageResponseMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.internal.di; @Module public class ApiModule { @Provides DashboardApi provideDashboardApi(DashboardRetrofitApi api) { return api; } @Provides
ImageResponseMapper provideImageResponseMapper(ImageResponseMapperImpl mapper) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.cache; public interface DashboardCache { boolean isValid();
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.cache; public interface DashboardCache { boolean isValid();
void cache(List<ImageEntity> values);
txusballesteros/Android-Clean-Testing
app/src/test/java/com/txusballesteros/testing/presentation/MainPresenterUnitTest.java
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // }
import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.List; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.presentation.model.ImageModelMapper;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterUnitTest extends UnitTest { @Mock MainPresenter.View viewMock;
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // Path: app/src/test/java/com/txusballesteros/testing/presentation/MainPresenterUnitTest.java import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.List; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.presentation.model.ImageModelMapper; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterUnitTest extends UnitTest { @Mock MainPresenter.View viewMock;
@Mock GetDashboardUseCase interactorMock;
txusballesteros/Android-Clean-Testing
app/src/test/java/com/txusballesteros/testing/presentation/MainPresenterUnitTest.java
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // }
import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.List; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.presentation.model.ImageModelMapper;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterUnitTest extends UnitTest { @Mock MainPresenter.View viewMock; @Mock GetDashboardUseCase interactorMock;
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // Path: app/src/test/java/com/txusballesteros/testing/presentation/MainPresenterUnitTest.java import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.List; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.presentation.model.ImageModelMapper; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterUnitTest extends UnitTest { @Mock MainPresenter.View viewMock; @Mock GetDashboardUseCase interactorMock;
@Mock ImageModelMapper mapperMock;
txusballesteros/Android-Clean-Testing
app/src/test/java/com/txusballesteros/testing/presentation/MainPresenterUnitTest.java
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // }
import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.List; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.presentation.model.ImageModelMapper;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterUnitTest extends UnitTest { @Mock MainPresenter.View viewMock; @Mock GetDashboardUseCase interactorMock; @Mock ImageModelMapper mapperMock;
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // Path: app/src/test/java/com/txusballesteros/testing/presentation/MainPresenterUnitTest.java import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.List; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.presentation.model.ImageModelMapper; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterUnitTest extends UnitTest { @Mock MainPresenter.View viewMock; @Mock GetDashboardUseCase interactorMock; @Mock ImageModelMapper mapperMock;
@Mock List<Image> interactorResultMock;
txusballesteros/Android-Clean-Testing
app/src/test/java/com/txusballesteros/testing/presentation/MainPresenterUnitTest.java
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // }
import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.List; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.presentation.model.ImageModelMapper;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterUnitTest extends UnitTest { @Mock MainPresenter.View viewMock; @Mock GetDashboardUseCase interactorMock; @Mock ImageModelMapper mapperMock; @Mock List<Image> interactorResultMock;
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // Path: app/src/test/java/com/txusballesteros/testing/presentation/MainPresenterUnitTest.java import org.junit.Test; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.List; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.presentation.model.ImageModelMapper; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterUnitTest extends UnitTest { @Mock MainPresenter.View viewMock; @Mock GetDashboardUseCase interactorMock; @Mock ImageModelMapper mapperMock; @Mock List<Image> interactorResultMock;
@Mock List<ImageModel> mapperResultMock;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/view/AbsActivity.java
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // }
import butterknife.ButterKnife; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view; public abstract class AbsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(onRequestLayout()); initializeInjection(); initializeViewsInjection(); }
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // Path: app/src/main/java/com/txusballesteros/testing/view/AbsActivity.java import butterknife.ButterKnife; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view; public abstract class AbsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(onRequestLayout()); initializeInjection(); initializeViewsInjection(); }
protected ApplicationComponent getApplicationComponent() {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/view/AbsActivity.java
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // }
import butterknife.ButterKnife; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view; public abstract class AbsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(onRequestLayout()); initializeInjection(); initializeViewsInjection(); } protected ApplicationComponent getApplicationComponent() {
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // Path: app/src/main/java/com/txusballesteros/testing/view/AbsActivity.java import butterknife.ButterKnife; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view; public abstract class AbsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(onRequestLayout()); initializeInjection(); initializeViewsInjection(); } protected ApplicationComponent getApplicationComponent() {
return ((Application)getApplication()).getApplicationComponent();
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/view/AbsActivity.java
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // }
import butterknife.ButterKnife; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view; public abstract class AbsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(onRequestLayout()); initializeInjection(); initializeViewsInjection(); } protected ApplicationComponent getApplicationComponent() { return ((Application)getApplication()).getApplicationComponent(); }
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // Path: app/src/main/java/com/txusballesteros/testing/view/AbsActivity.java import butterknife.ButterKnife; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view; public abstract class AbsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(onRequestLayout()); initializeInjection(); initializeViewsInjection(); } protected ApplicationComponent getApplicationComponent() { return ((Application)getApplication()).getApplicationComponent(); }
protected DependenciesInjector getDependenciesInjector() {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/view/internal/di/ViewModule.java
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // }
import com.txusballesteros.testing.presentation.MainPresenter; import dagger.Module; import dagger.Provides;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view.internal.di; @Module public class ViewModule {
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/view/internal/di/ViewModule.java import com.txusballesteros.testing.presentation.MainPresenter; import dagger.Module; import dagger.Provides; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view.internal.di; @Module public class ViewModule {
private MainPresenter.View mainPresenterView;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/transformer/internal/di/TranformerModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/GiphyImageUriTransformer.java // public class GiphyImageUriTransformer implements ImageUriTransformer { // public static final String GIPHY_IMAGE_URI_PATTERN = "http://i.giphy.com/%s.gif"; // // @Inject // public GiphyImageUriTransformer() { } // // @Override // public String transform(String imageId) { // return String.format(GIPHY_IMAGE_URI_PATTERN, imageId); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // }
import dagger.Provides; import com.txusballesteros.testing.data.api.transformer.GiphyImageUriTransformer; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import javax.inject.Singleton; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.transformer.internal.di; @Module public class TranformerModule { @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/GiphyImageUriTransformer.java // public class GiphyImageUriTransformer implements ImageUriTransformer { // public static final String GIPHY_IMAGE_URI_PATTERN = "http://i.giphy.com/%s.gif"; // // @Inject // public GiphyImageUriTransformer() { } // // @Override // public String transform(String imageId) { // return String.format(GIPHY_IMAGE_URI_PATTERN, imageId); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/internal/di/TranformerModule.java import dagger.Provides; import com.txusballesteros.testing.data.api.transformer.GiphyImageUriTransformer; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import javax.inject.Singleton; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.transformer.internal.di; @Module public class TranformerModule { @Provides @Singleton
ImageUriTransformer provideImageUriTransformer(GiphyImageUriTransformer transformer) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/transformer/internal/di/TranformerModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/GiphyImageUriTransformer.java // public class GiphyImageUriTransformer implements ImageUriTransformer { // public static final String GIPHY_IMAGE_URI_PATTERN = "http://i.giphy.com/%s.gif"; // // @Inject // public GiphyImageUriTransformer() { } // // @Override // public String transform(String imageId) { // return String.format(GIPHY_IMAGE_URI_PATTERN, imageId); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // }
import dagger.Provides; import com.txusballesteros.testing.data.api.transformer.GiphyImageUriTransformer; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import javax.inject.Singleton; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.transformer.internal.di; @Module public class TranformerModule { @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/GiphyImageUriTransformer.java // public class GiphyImageUriTransformer implements ImageUriTransformer { // public static final String GIPHY_IMAGE_URI_PATTERN = "http://i.giphy.com/%s.gif"; // // @Inject // public GiphyImageUriTransformer() { } // // @Override // public String transform(String imageId) { // return String.format(GIPHY_IMAGE_URI_PATTERN, imageId); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/internal/di/TranformerModule.java import dagger.Provides; import com.txusballesteros.testing.data.api.transformer.GiphyImageUriTransformer; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import javax.inject.Singleton; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.transformer.internal.di; @Module public class TranformerModule { @Provides @Singleton
ImageUriTransformer provideImageUriTransformer(GiphyImageUriTransformer transformer) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/cache/internal/di/CachesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardMemoryCache.java // public class DashboardMemoryCache extends AbsCache implements DashboardCache { // private final List<ImageEntity> cache; // // @Inject // public DashboardMemoryCache() { // this.cache = new ArrayList<>(); // } // // @Override // public boolean isValid() { // return isValidCache(); // } // // @Override // public void cache(List<ImageEntity> values) { // cache.clear(); // cache.addAll(values); // updateLastStorageTime(); // } // // @Override // public List<ImageEntity> get() { // return cache; // } // }
import dagger.Provides; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.cache.DashboardMemoryCache; import javax.inject.Singleton; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.cache.internal.di; @Module public class CachesModule { @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardMemoryCache.java // public class DashboardMemoryCache extends AbsCache implements DashboardCache { // private final List<ImageEntity> cache; // // @Inject // public DashboardMemoryCache() { // this.cache = new ArrayList<>(); // } // // @Override // public boolean isValid() { // return isValidCache(); // } // // @Override // public void cache(List<ImageEntity> values) { // cache.clear(); // cache.addAll(values); // updateLastStorageTime(); // } // // @Override // public List<ImageEntity> get() { // return cache; // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/cache/internal/di/CachesModule.java import dagger.Provides; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.cache.DashboardMemoryCache; import javax.inject.Singleton; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.cache.internal.di; @Module public class CachesModule { @Provides @Singleton
DashboardCache provideDashboardCache(DashboardMemoryCache cache) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/cache/internal/di/CachesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardMemoryCache.java // public class DashboardMemoryCache extends AbsCache implements DashboardCache { // private final List<ImageEntity> cache; // // @Inject // public DashboardMemoryCache() { // this.cache = new ArrayList<>(); // } // // @Override // public boolean isValid() { // return isValidCache(); // } // // @Override // public void cache(List<ImageEntity> values) { // cache.clear(); // cache.addAll(values); // updateLastStorageTime(); // } // // @Override // public List<ImageEntity> get() { // return cache; // } // }
import dagger.Provides; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.cache.DashboardMemoryCache; import javax.inject.Singleton; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.cache.internal.di; @Module public class CachesModule { @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardMemoryCache.java // public class DashboardMemoryCache extends AbsCache implements DashboardCache { // private final List<ImageEntity> cache; // // @Inject // public DashboardMemoryCache() { // this.cache = new ArrayList<>(); // } // // @Override // public boolean isValid() { // return isValidCache(); // } // // @Override // public void cache(List<ImageEntity> values) { // cache.clear(); // cache.addAll(values); // updateLastStorageTime(); // } // // @Override // public List<ImageEntity> get() { // return cache; // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/cache/internal/di/CachesModule.java import dagger.Provides; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.cache.DashboardMemoryCache; import javax.inject.Singleton; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.cache.internal.di; @Module public class CachesModule { @Provides @Singleton
DashboardCache provideDashboardCache(DashboardMemoryCache cache) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import javax.inject.Inject; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource; public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { private final DashboardApi api;
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java import javax.inject.Inject; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource; public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { private final DashboardApi api;
private final ImageResponseMapper mapper;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import javax.inject.Inject; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource; public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { private final DashboardApi api; private final ImageResponseMapper mapper; @Inject public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { this.api = api; this.mapper = mapper; } @Override
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java import javax.inject.Inject; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource; public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { private final DashboardApi api; private final ImageResponseMapper mapper; @Inject public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { this.api = api; this.mapper = mapper; } @Override
public List<ImageEntity> getDashboard() {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import javax.inject.Inject; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource; public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { private final DashboardApi api; private final ImageResponseMapper mapper; @Inject public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { this.api = api; this.mapper = mapper; } @Override public List<ImageEntity> getDashboard() {
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java import javax.inject.Inject; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource; public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { private final DashboardApi api; private final ImageResponseMapper mapper; @Inject public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { this.api = api; this.mapper = mapper; } @Override public List<ImageEntity> getDashboard() {
final List<ImageResponse> images = api.getDashboard();
txusballesteros/Android-Clean-Testing
app/src/androidTest/java/com/txusballesteros/testing/TestingApplication.java
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationComponent.java // @Singleton // @Component(modules = TestingApplicationModule.class) // public interface TestingApplicationComponent extends ApplicationComponent { // void inject(TestingApplication application); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationModule.java // @Module ( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class TestingApplicationModule implements ApplicationModule { // private final Application application; // // public TestingApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new TestingDependenciesInjector(); // } // }
import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerTestingApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.TestingApplicationComponent; import com.txusballesteros.testing.internal.di.TestingApplicationModule;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class TestingApplication extends Application { private TestingApplicationComponent applicationComponent;
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationComponent.java // @Singleton // @Component(modules = TestingApplicationModule.class) // public interface TestingApplicationComponent extends ApplicationComponent { // void inject(TestingApplication application); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationModule.java // @Module ( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class TestingApplicationModule implements ApplicationModule { // private final Application application; // // public TestingApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new TestingDependenciesInjector(); // } // } // Path: app/src/androidTest/java/com/txusballesteros/testing/TestingApplication.java import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerTestingApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.TestingApplicationComponent; import com.txusballesteros.testing.internal.di.TestingApplicationModule; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class TestingApplication extends Application { private TestingApplicationComponent applicationComponent;
@Inject DependenciesInjector injector;
txusballesteros/Android-Clean-Testing
app/src/androidTest/java/com/txusballesteros/testing/TestingApplication.java
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationComponent.java // @Singleton // @Component(modules = TestingApplicationModule.class) // public interface TestingApplicationComponent extends ApplicationComponent { // void inject(TestingApplication application); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationModule.java // @Module ( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class TestingApplicationModule implements ApplicationModule { // private final Application application; // // public TestingApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new TestingDependenciesInjector(); // } // }
import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerTestingApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.TestingApplicationComponent; import com.txusballesteros.testing.internal.di.TestingApplicationModule;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class TestingApplication extends Application { private TestingApplicationComponent applicationComponent; @Inject DependenciesInjector injector; @Override public void onCreate() { super.onCreate(); initializeInjection(); } private void initializeInjection() { applicationComponent = DaggerTestingApplicationComponent .builder()
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationComponent.java // @Singleton // @Component(modules = TestingApplicationModule.class) // public interface TestingApplicationComponent extends ApplicationComponent { // void inject(TestingApplication application); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationModule.java // @Module ( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class TestingApplicationModule implements ApplicationModule { // private final Application application; // // public TestingApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new TestingDependenciesInjector(); // } // } // Path: app/src/androidTest/java/com/txusballesteros/testing/TestingApplication.java import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerTestingApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.TestingApplicationComponent; import com.txusballesteros.testing.internal.di.TestingApplicationModule; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class TestingApplication extends Application { private TestingApplicationComponent applicationComponent; @Inject DependenciesInjector injector; @Override public void onCreate() { super.onCreate(); initializeInjection(); } private void initializeInjection() { applicationComponent = DaggerTestingApplicationComponent .builder()
.testingApplicationModule(new TestingApplicationModule(this))
txusballesteros/Android-Clean-Testing
app/src/androidTest/java/com/txusballesteros/testing/TestingApplication.java
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationComponent.java // @Singleton // @Component(modules = TestingApplicationModule.class) // public interface TestingApplicationComponent extends ApplicationComponent { // void inject(TestingApplication application); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationModule.java // @Module ( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class TestingApplicationModule implements ApplicationModule { // private final Application application; // // public TestingApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new TestingDependenciesInjector(); // } // }
import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerTestingApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.TestingApplicationComponent; import com.txusballesteros.testing.internal.di.TestingApplicationModule;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class TestingApplication extends Application { private TestingApplicationComponent applicationComponent; @Inject DependenciesInjector injector; @Override public void onCreate() { super.onCreate(); initializeInjection(); } private void initializeInjection() { applicationComponent = DaggerTestingApplicationComponent .builder() .testingApplicationModule(new TestingApplicationModule(this)) .build(); applicationComponent.inject(this); } @Override
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationComponent.java // @Singleton // @Component(modules = TestingApplicationModule.class) // public interface TestingApplicationComponent extends ApplicationComponent { // void inject(TestingApplication application); // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationModule.java // @Module ( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class TestingApplicationModule implements ApplicationModule { // private final Application application; // // public TestingApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new TestingDependenciesInjector(); // } // } // Path: app/src/androidTest/java/com/txusballesteros/testing/TestingApplication.java import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerTestingApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.TestingApplicationComponent; import com.txusballesteros.testing.internal.di.TestingApplicationModule; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class TestingApplication extends Application { private TestingApplicationComponent applicationComponent; @Inject DependenciesInjector injector; @Override public void onCreate() { super.onCreate(); initializeInjection(); } private void initializeInjection() { applicationComponent = DaggerTestingApplicationComponent .builder() .testingApplicationModule(new TestingApplicationModule(this)) .build(); applicationComponent.inject(this); } @Override
public ApplicationComponent getApplicationComponent() {
txusballesteros/Android-Clean-Testing
app/src/androidTest/java/com/txusballesteros/testing/instrumentation/view/MainActivityTest.java
// Path: app/src/androidTest/java/com/txusballesteros/testing/instrumentation/InstrumentationTest.java // @RunWith(AndroidJUnit4.class) // public abstract class InstrumentationTest { // @Before // public final void setup() { // onSetup(); // } // // protected void onSetup() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/view/MainActivity.java // public class MainActivity extends AbsActivity implements MainPresenter.View { // @Inject MainPresenter presenter; // @Inject ImageLoader imageLoader; // @Bind(R.id.list) RecyclerView listView; // private DashboardListAdapter listAdapter; // // @Override // int onRequestLayout() { // return R.layout.activity_main; // } // // @Override // void onViewReady() { // initializeList(); // } // // private void initializeList() { // listAdapter = new DashboardListAdapter(this, imageLoader); // listView.setLayoutManager(new GridLayoutManager(this, 2)); // listView.setHasFixedSize(true); // listView.setAdapter(listAdapter); // } // // @Override // void onInitializeInjection() { // getDependenciesInjector().inject(this); // } // // @Override // protected void onStart() { // super.onStart(); // presenter.onStart(); // } // // @Override // protected void onStop() { // super.onStop(); // presenter.onStop(); // } // // @Override // public void renderDashboard(List<ImageModel> images) { // listAdapter.addAll(images); // } // // @Override // public void renderError() { } // }
import com.txusballesteros.testing.view.MainActivity; import org.junit.Rule; import org.junit.Test; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withId; import android.content.Intent; import android.support.test.rule.ActivityTestRule; import android.test.suitebuilder.annotation.LargeTest; import com.txusballesteros.testing.R; import com.txusballesteros.testing.instrumentation.InstrumentationTest;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.instrumentation.view; @LargeTest public class MainActivityTest extends InstrumentationTest {
// Path: app/src/androidTest/java/com/txusballesteros/testing/instrumentation/InstrumentationTest.java // @RunWith(AndroidJUnit4.class) // public abstract class InstrumentationTest { // @Before // public final void setup() { // onSetup(); // } // // protected void onSetup() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/view/MainActivity.java // public class MainActivity extends AbsActivity implements MainPresenter.View { // @Inject MainPresenter presenter; // @Inject ImageLoader imageLoader; // @Bind(R.id.list) RecyclerView listView; // private DashboardListAdapter listAdapter; // // @Override // int onRequestLayout() { // return R.layout.activity_main; // } // // @Override // void onViewReady() { // initializeList(); // } // // private void initializeList() { // listAdapter = new DashboardListAdapter(this, imageLoader); // listView.setLayoutManager(new GridLayoutManager(this, 2)); // listView.setHasFixedSize(true); // listView.setAdapter(listAdapter); // } // // @Override // void onInitializeInjection() { // getDependenciesInjector().inject(this); // } // // @Override // protected void onStart() { // super.onStart(); // presenter.onStart(); // } // // @Override // protected void onStop() { // super.onStop(); // presenter.onStop(); // } // // @Override // public void renderDashboard(List<ImageModel> images) { // listAdapter.addAll(images); // } // // @Override // public void renderError() { } // } // Path: app/src/androidTest/java/com/txusballesteros/testing/instrumentation/view/MainActivityTest.java import com.txusballesteros.testing.view.MainActivity; import org.junit.Rule; import org.junit.Test; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withId; import android.content.Intent; import android.support.test.rule.ActivityTestRule; import android.test.suitebuilder.annotation.LargeTest; import com.txusballesteros.testing.R; import com.txusballesteros.testing.instrumentation.InstrumentationTest; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.instrumentation.view; @LargeTest public class MainActivityTest extends InstrumentationTest {
@Rule public ActivityTestRule<MainActivity> activityRule
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/internal/di/RepositoriesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java // public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { // private final DashboardDatasource datasource; // private final DashboardCache cache; // private final ImageEntityMapper mapper; // // @Inject // public DashboardRepositoryImpl(DashboardDatasource datasource, // DashboardCache cache, // ImageEntityMapper mapper) { // this.datasource = datasource; // this.cache = cache; // this.mapper = mapper; // } // // @Override // public void getDashboard(final Callback callback) { // try { // List<Image> result; // if (cache.isValid()) { // result = mapper.map(cache.get()); // } else { // final List<ImageEntity> images = datasource.getDashboard(); // cache.cache(images); // result = mapper.map(images); // } // callback.onSuccess(result); // } catch (Exception error) { // callback.onError(); // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.DashboardRepositoryImpl; import com.txusballesteros.testing.domain.repository.DashboardRepository; import javax.inject.Singleton; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.internal.di; @Module public class RepositoriesModule { @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java // public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { // private final DashboardDatasource datasource; // private final DashboardCache cache; // private final ImageEntityMapper mapper; // // @Inject // public DashboardRepositoryImpl(DashboardDatasource datasource, // DashboardCache cache, // ImageEntityMapper mapper) { // this.datasource = datasource; // this.cache = cache; // this.mapper = mapper; // } // // @Override // public void getDashboard(final Callback callback) { // try { // List<Image> result; // if (cache.isValid()) { // result = mapper.map(cache.get()); // } else { // final List<ImageEntity> images = datasource.getDashboard(); // cache.cache(images); // result = mapper.map(images); // } // callback.onSuccess(result); // } catch (Exception error) { // callback.onError(); // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/internal/di/RepositoriesModule.java import dagger.Provides; import com.txusballesteros.testing.data.DashboardRepositoryImpl; import com.txusballesteros.testing.domain.repository.DashboardRepository; import javax.inject.Singleton; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.internal.di; @Module public class RepositoriesModule { @Provides @Singleton
DashboardRepository provideDashboardRepository(DashboardRepositoryImpl repository) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/internal/di/RepositoriesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java // public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { // private final DashboardDatasource datasource; // private final DashboardCache cache; // private final ImageEntityMapper mapper; // // @Inject // public DashboardRepositoryImpl(DashboardDatasource datasource, // DashboardCache cache, // ImageEntityMapper mapper) { // this.datasource = datasource; // this.cache = cache; // this.mapper = mapper; // } // // @Override // public void getDashboard(final Callback callback) { // try { // List<Image> result; // if (cache.isValid()) { // result = mapper.map(cache.get()); // } else { // final List<ImageEntity> images = datasource.getDashboard(); // cache.cache(images); // result = mapper.map(images); // } // callback.onSuccess(result); // } catch (Exception error) { // callback.onError(); // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.DashboardRepositoryImpl; import com.txusballesteros.testing.domain.repository.DashboardRepository; import javax.inject.Singleton; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.internal.di; @Module public class RepositoriesModule { @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java // public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { // private final DashboardDatasource datasource; // private final DashboardCache cache; // private final ImageEntityMapper mapper; // // @Inject // public DashboardRepositoryImpl(DashboardDatasource datasource, // DashboardCache cache, // ImageEntityMapper mapper) { // this.datasource = datasource; // this.cache = cache; // this.mapper = mapper; // } // // @Override // public void getDashboard(final Callback callback) { // try { // List<Image> result; // if (cache.isValid()) { // result = mapper.map(cache.get()); // } else { // final List<ImageEntity> images = datasource.getDashboard(); // cache.cache(images); // result = mapper.map(images); // } // callback.onSuccess(result); // } catch (Exception error) { // callback.onError(); // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/internal/di/RepositoriesModule.java import dagger.Provides; import com.txusballesteros.testing.data.DashboardRepositoryImpl; import com.txusballesteros.testing.domain.repository.DashboardRepository; import javax.inject.Singleton; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.internal.di; @Module public class RepositoriesModule { @Provides @Singleton
DashboardRepository provideDashboardRepository(DashboardRepositoryImpl repository) {
txusballesteros/Android-Clean-Testing
app/src/test/java/com/txusballesteros/testing/data/api/DashboardRetrofitApiUnitTest.java
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/DashboardEndpoint.java // public interface DashboardEndpoint { // @GET("v1/gifs/trending") // Call<DashboardListEndpointResponse> getDashboard(@Query("api_key") String apiKey); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // }
import org.mockito.Mock; import java.io.IOException; import retrofit2.Call; import retrofit2.Response; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.data.api.endpoint.DashboardEndpoint; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import org.junit.Test;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api; public class DashboardRetrofitApiUnitTest extends UnitTest { @Mock DashboardEndpoint endpointMock;
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/DashboardEndpoint.java // public interface DashboardEndpoint { // @GET("v1/gifs/trending") // Call<DashboardListEndpointResponse> getDashboard(@Query("api_key") String apiKey); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // Path: app/src/test/java/com/txusballesteros/testing/data/api/DashboardRetrofitApiUnitTest.java import org.mockito.Mock; import java.io.IOException; import retrofit2.Call; import retrofit2.Response; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.data.api.endpoint.DashboardEndpoint; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import org.junit.Test; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api; public class DashboardRetrofitApiUnitTest extends UnitTest { @Mock DashboardEndpoint endpointMock;
@Mock ImageResponseMapper mapperMock;
txusballesteros/Android-Clean-Testing
app/src/test/java/com/txusballesteros/testing/data/api/DashboardRetrofitApiUnitTest.java
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/DashboardEndpoint.java // public interface DashboardEndpoint { // @GET("v1/gifs/trending") // Call<DashboardListEndpointResponse> getDashboard(@Query("api_key") String apiKey); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // }
import org.mockito.Mock; import java.io.IOException; import retrofit2.Call; import retrofit2.Response; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.data.api.endpoint.DashboardEndpoint; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import org.junit.Test;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api; public class DashboardRetrofitApiUnitTest extends UnitTest { @Mock DashboardEndpoint endpointMock; @Mock ImageResponseMapper mapperMock;
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/DashboardEndpoint.java // public interface DashboardEndpoint { // @GET("v1/gifs/trending") // Call<DashboardListEndpointResponse> getDashboard(@Query("api_key") String apiKey); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java // public interface ImageResponseMapper { // List<ImageResponse> map(DashboardListEndpointResponse source); // List<ImageEntity> map(List<ImageResponse> source); // ImageEntity map(ImageResponse source); // ImageResponse map(DashboardEndpointResponse source); // } // Path: app/src/test/java/com/txusballesteros/testing/data/api/DashboardRetrofitApiUnitTest.java import org.mockito.Mock; import java.io.IOException; import retrofit2.Call; import retrofit2.Response; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.data.api.endpoint.DashboardEndpoint; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.model.ImageResponseMapper; import org.junit.Test; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api; public class DashboardRetrofitApiUnitTest extends UnitTest { @Mock DashboardEndpoint endpointMock; @Mock ImageResponseMapper mapperMock;
@Mock Call<DashboardListEndpointResponse> apiCallerMock;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/Application.java
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationComponent.java // @Singleton // @Component(modules = RuntimeApplicationModule.class) // public interface RuntimeApplicationComponent extends ApplicationComponent { // void inject(Application application); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationModule.java // @Module( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class RuntimeApplicationModule implements ApplicationModule { // private Application application; // // public RuntimeApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new RuntimeDependenciesInjector(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeDependenciesInjector.java // public class RuntimeDependenciesInjector implements DependenciesInjector { // @Override // public void inject(MainActivity client) { // DaggerRuntimeActivityComponent.builder() // .applicationComponent(getApplicationComponent(client)) // .runtimeActivityModule(new RuntimeActivityModule(client)) // .viewModule(new ViewModule(client)) // .build() // .inject(client); // } // // private ApplicationComponent getApplicationComponent(Activity activity) { // return ((Application)activity.getApplication()).getApplicationComponent(); // } // }
import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerRuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.RuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.RuntimeApplicationModule; import com.txusballesteros.testing.internal.di.RuntimeDependenciesInjector;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class Application extends android.app.Application { private RuntimeApplicationComponent applicationComponent;
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationComponent.java // @Singleton // @Component(modules = RuntimeApplicationModule.class) // public interface RuntimeApplicationComponent extends ApplicationComponent { // void inject(Application application); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationModule.java // @Module( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class RuntimeApplicationModule implements ApplicationModule { // private Application application; // // public RuntimeApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new RuntimeDependenciesInjector(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeDependenciesInjector.java // public class RuntimeDependenciesInjector implements DependenciesInjector { // @Override // public void inject(MainActivity client) { // DaggerRuntimeActivityComponent.builder() // .applicationComponent(getApplicationComponent(client)) // .runtimeActivityModule(new RuntimeActivityModule(client)) // .viewModule(new ViewModule(client)) // .build() // .inject(client); // } // // private ApplicationComponent getApplicationComponent(Activity activity) { // return ((Application)activity.getApplication()).getApplicationComponent(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/Application.java import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerRuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.RuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.RuntimeApplicationModule; import com.txusballesteros.testing.internal.di.RuntimeDependenciesInjector; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class Application extends android.app.Application { private RuntimeApplicationComponent applicationComponent;
@Inject DependenciesInjector injector;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/Application.java
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationComponent.java // @Singleton // @Component(modules = RuntimeApplicationModule.class) // public interface RuntimeApplicationComponent extends ApplicationComponent { // void inject(Application application); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationModule.java // @Module( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class RuntimeApplicationModule implements ApplicationModule { // private Application application; // // public RuntimeApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new RuntimeDependenciesInjector(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeDependenciesInjector.java // public class RuntimeDependenciesInjector implements DependenciesInjector { // @Override // public void inject(MainActivity client) { // DaggerRuntimeActivityComponent.builder() // .applicationComponent(getApplicationComponent(client)) // .runtimeActivityModule(new RuntimeActivityModule(client)) // .viewModule(new ViewModule(client)) // .build() // .inject(client); // } // // private ApplicationComponent getApplicationComponent(Activity activity) { // return ((Application)activity.getApplication()).getApplicationComponent(); // } // }
import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerRuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.RuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.RuntimeApplicationModule; import com.txusballesteros.testing.internal.di.RuntimeDependenciesInjector;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class Application extends android.app.Application { private RuntimeApplicationComponent applicationComponent; @Inject DependenciesInjector injector; @Override public void onCreate() { super.onCreate(); initializeInjection(); } private void initializeInjection() { applicationComponent = DaggerRuntimeApplicationComponent.builder()
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationComponent.java // @Singleton // @Component(modules = RuntimeApplicationModule.class) // public interface RuntimeApplicationComponent extends ApplicationComponent { // void inject(Application application); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationModule.java // @Module( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class RuntimeApplicationModule implements ApplicationModule { // private Application application; // // public RuntimeApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new RuntimeDependenciesInjector(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeDependenciesInjector.java // public class RuntimeDependenciesInjector implements DependenciesInjector { // @Override // public void inject(MainActivity client) { // DaggerRuntimeActivityComponent.builder() // .applicationComponent(getApplicationComponent(client)) // .runtimeActivityModule(new RuntimeActivityModule(client)) // .viewModule(new ViewModule(client)) // .build() // .inject(client); // } // // private ApplicationComponent getApplicationComponent(Activity activity) { // return ((Application)activity.getApplication()).getApplicationComponent(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/Application.java import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerRuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.RuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.RuntimeApplicationModule; import com.txusballesteros.testing.internal.di.RuntimeDependenciesInjector; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class Application extends android.app.Application { private RuntimeApplicationComponent applicationComponent; @Inject DependenciesInjector injector; @Override public void onCreate() { super.onCreate(); initializeInjection(); } private void initializeInjection() { applicationComponent = DaggerRuntimeApplicationComponent.builder()
.runtimeApplicationModule(new RuntimeApplicationModule(this))
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/Application.java
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationComponent.java // @Singleton // @Component(modules = RuntimeApplicationModule.class) // public interface RuntimeApplicationComponent extends ApplicationComponent { // void inject(Application application); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationModule.java // @Module( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class RuntimeApplicationModule implements ApplicationModule { // private Application application; // // public RuntimeApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new RuntimeDependenciesInjector(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeDependenciesInjector.java // public class RuntimeDependenciesInjector implements DependenciesInjector { // @Override // public void inject(MainActivity client) { // DaggerRuntimeActivityComponent.builder() // .applicationComponent(getApplicationComponent(client)) // .runtimeActivityModule(new RuntimeActivityModule(client)) // .viewModule(new ViewModule(client)) // .build() // .inject(client); // } // // private ApplicationComponent getApplicationComponent(Activity activity) { // return ((Application)activity.getApplication()).getApplicationComponent(); // } // }
import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerRuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.RuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.RuntimeApplicationModule; import com.txusballesteros.testing.internal.di.RuntimeDependenciesInjector;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class Application extends android.app.Application { private RuntimeApplicationComponent applicationComponent; @Inject DependenciesInjector injector; @Override public void onCreate() { super.onCreate(); initializeInjection(); } private void initializeInjection() { applicationComponent = DaggerRuntimeApplicationComponent.builder() .runtimeApplicationModule(new RuntimeApplicationModule(this)) .build(); applicationComponent.inject(this); }
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/DependenciesInjector.java // public interface DependenciesInjector { // void inject(MainActivity client); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationComponent.java // @Singleton // @Component(modules = RuntimeApplicationModule.class) // public interface RuntimeApplicationComponent extends ApplicationComponent { // void inject(Application application); // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationModule.java // @Module( includes = { // InstrumentationModule.class, // RepositoriesModule.class, // DatasourcesModule.class, // CachesModule.class, // ApiModule.class, // TranformerModule.class, // EndpointsModule.class // }) // public class RuntimeApplicationModule implements ApplicationModule { // private Application application; // // public RuntimeApplicationModule(Application application) { // this.application = application; // } // // @Override @Provides // public Application provideApplication() { // return application; // } // // @Override @Provides @Singleton // public ThreadExecutor provideThreadExecutor(JobExecutor executor) { // return executor; // } // // @Override @Provides @Singleton // public PostExecutionThread providePostExecutionThread() { // return UIThread.getInstance(); // } // // @Override @Provides @Singleton // public DependenciesInjector provideDependenciesInjector() { // return new RuntimeDependenciesInjector(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeDependenciesInjector.java // public class RuntimeDependenciesInjector implements DependenciesInjector { // @Override // public void inject(MainActivity client) { // DaggerRuntimeActivityComponent.builder() // .applicationComponent(getApplicationComponent(client)) // .runtimeActivityModule(new RuntimeActivityModule(client)) // .viewModule(new ViewModule(client)) // .build() // .inject(client); // } // // private ApplicationComponent getApplicationComponent(Activity activity) { // return ((Application)activity.getApplication()).getApplicationComponent(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/Application.java import javax.inject.Inject; import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.DaggerRuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.DependenciesInjector; import com.txusballesteros.testing.internal.di.RuntimeApplicationComponent; import com.txusballesteros.testing.internal.di.RuntimeApplicationModule; import com.txusballesteros.testing.internal.di.RuntimeDependenciesInjector; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing; public class Application extends android.app.Application { private RuntimeApplicationComponent applicationComponent; @Inject DependenciesInjector injector; @Override public void onCreate() { super.onCreate(); initializeInjection(); } private void initializeInjection() { applicationComponent = DaggerRuntimeApplicationComponent.builder() .runtimeApplicationModule(new RuntimeApplicationModule(this)) .build(); applicationComponent.inject(this); }
public ApplicationComponent getApplicationComponent() {
txusballesteros/Android-Clean-Testing
app/src/test/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperUnitTest.java
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // }
import org.mockito.Mock; import java.util.Iterator; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import android.net.Uri; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import org.junit.Test;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.model; public class ImageEntityMapperUnitTest extends UnitTest { private final static Uri TESTING_IMAGE_URL = Uri.parse("http://developer.android.com/"); @Mock ImageEntity imageMock; @Mock List<ImageEntity> imageListMock; @Mock Iterator<ImageEntity> imageIteratorMock; private ImageEntityMapper mapper; @Override protected void onSetup() { mapper = new ImageEntityMapperImpl(); } public void shouldMapOneImage() { doReturn(TESTING_IMAGE_URL).when(imageMock).getUrl();
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // Path: app/src/test/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperUnitTest.java import org.mockito.Mock; import java.util.Iterator; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import android.net.Uri; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import org.junit.Test; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.model; public class ImageEntityMapperUnitTest extends UnitTest { private final static Uri TESTING_IMAGE_URL = Uri.parse("http://developer.android.com/"); @Mock ImageEntity imageMock; @Mock List<ImageEntity> imageListMock; @Mock Iterator<ImageEntity> imageIteratorMock; private ImageEntityMapper mapper; @Override protected void onSetup() { mapper = new ImageEntityMapperImpl(); } public void shouldMapOneImage() { doReturn(TESTING_IMAGE_URL).when(imageMock).getUrl();
final Image mapResult = mapper.map(imageMock);
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/view/instrumentation/internal/di/InstrumentationModule.java
// Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/GlideImageLoader.java // public class GlideImageLoader implements ImageLoader { // private final Application application; // // @Inject // public GlideImageLoader(Application application) { // this.application = application; // } // // @Override // public void loadImageAsGif(Uri imageUrl, ImageView imageView) { // Glide.with(application) // .load(imageUrl) // .asGif() // .placeholder(R.drawable.ic_cloud_download_48dp) // .into(imageView); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // }
import dagger.Provides; import com.txusballesteros.testing.view.instrumentation.GlideImageLoader; import com.txusballesteros.testing.view.instrumentation.ImageLoader; import javax.inject.Singleton; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view.instrumentation.internal.di; @Module public class InstrumentationModule { @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/GlideImageLoader.java // public class GlideImageLoader implements ImageLoader { // private final Application application; // // @Inject // public GlideImageLoader(Application application) { // this.application = application; // } // // @Override // public void loadImageAsGif(Uri imageUrl, ImageView imageView) { // Glide.with(application) // .load(imageUrl) // .asGif() // .placeholder(R.drawable.ic_cloud_download_48dp) // .into(imageView); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // } // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/internal/di/InstrumentationModule.java import dagger.Provides; import com.txusballesteros.testing.view.instrumentation.GlideImageLoader; import com.txusballesteros.testing.view.instrumentation.ImageLoader; import javax.inject.Singleton; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view.instrumentation.internal.di; @Module public class InstrumentationModule { @Provides @Singleton
ImageLoader provideImageLoader(GlideImageLoader imageLoader) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/view/instrumentation/internal/di/InstrumentationModule.java
// Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/GlideImageLoader.java // public class GlideImageLoader implements ImageLoader { // private final Application application; // // @Inject // public GlideImageLoader(Application application) { // this.application = application; // } // // @Override // public void loadImageAsGif(Uri imageUrl, ImageView imageView) { // Glide.with(application) // .load(imageUrl) // .asGif() // .placeholder(R.drawable.ic_cloud_download_48dp) // .into(imageView); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // }
import dagger.Provides; import com.txusballesteros.testing.view.instrumentation.GlideImageLoader; import com.txusballesteros.testing.view.instrumentation.ImageLoader; import javax.inject.Singleton; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view.instrumentation.internal.di; @Module public class InstrumentationModule { @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/GlideImageLoader.java // public class GlideImageLoader implements ImageLoader { // private final Application application; // // @Inject // public GlideImageLoader(Application application) { // this.application = application; // } // // @Override // public void loadImageAsGif(Uri imageUrl, ImageView imageView) { // Glide.with(application) // .load(imageUrl) // .asGif() // .placeholder(R.drawable.ic_cloud_download_48dp) // .into(imageView); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // } // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/internal/di/InstrumentationModule.java import dagger.Provides; import com.txusballesteros.testing.view.instrumentation.GlideImageLoader; import com.txusballesteros.testing.view.instrumentation.ImageLoader; import javax.inject.Singleton; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view.instrumentation.internal.di; @Module public class InstrumentationModule { @Provides @Singleton
ImageLoader provideImageLoader(GlideImageLoader imageLoader) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // }
import java.util.List; import javax.inject.Inject; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.repository.DashboardRepository;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data; public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { private final DashboardDatasource datasource;
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java import java.util.List; import javax.inject.Inject; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.repository.DashboardRepository; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data; public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { private final DashboardDatasource datasource;
private final DashboardCache cache;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // }
import java.util.List; import javax.inject.Inject; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.repository.DashboardRepository;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data; public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { private final DashboardDatasource datasource; private final DashboardCache cache;
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java import java.util.List; import javax.inject.Inject; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.repository.DashboardRepository; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data; public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { private final DashboardDatasource datasource; private final DashboardCache cache;
private final ImageEntityMapper mapper;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // }
import java.util.List; import javax.inject.Inject; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.repository.DashboardRepository;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data; public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { private final DashboardDatasource datasource; private final DashboardCache cache; private final ImageEntityMapper mapper; @Inject public DashboardRepositoryImpl(DashboardDatasource datasource, DashboardCache cache, ImageEntityMapper mapper) { this.datasource = datasource; this.cache = cache; this.mapper = mapper; } @Override public void getDashboard(final Callback callback) { try {
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java import java.util.List; import javax.inject.Inject; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.repository.DashboardRepository; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data; public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { private final DashboardDatasource datasource; private final DashboardCache cache; private final ImageEntityMapper mapper; @Inject public DashboardRepositoryImpl(DashboardDatasource datasource, DashboardCache cache, ImageEntityMapper mapper) { this.datasource = datasource; this.cache = cache; this.mapper = mapper; } @Override public void getDashboard(final Callback callback) { try {
List<Image> result;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // }
import java.util.List; import javax.inject.Inject; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.repository.DashboardRepository;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data; public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { private final DashboardDatasource datasource; private final DashboardCache cache; private final ImageEntityMapper mapper; @Inject public DashboardRepositoryImpl(DashboardDatasource datasource, DashboardCache cache, ImageEntityMapper mapper) { this.datasource = datasource; this.cache = cache; this.mapper = mapper; } @Override public void getDashboard(final Callback callback) { try { List<Image> result; if (cache.isValid()) { result = mapper.map(cache.get()); } else {
// Path: app/src/main/java/com/txusballesteros/testing/data/cache/DashboardCache.java // public interface DashboardCache { // boolean isValid(); // void cache(List<ImageEntity> values); // List<ImageEntity> get(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/DashboardRepositoryImpl.java import java.util.List; import javax.inject.Inject; import com.txusballesteros.testing.data.cache.DashboardCache; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.repository.DashboardRepository; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data; public class DashboardRepositoryImpl extends AbsRepository implements DashboardRepository { private final DashboardDatasource datasource; private final DashboardCache cache; private final ImageEntityMapper mapper; @Inject public DashboardRepositoryImpl(DashboardDatasource datasource, DashboardCache cache, ImageEntityMapper mapper) { this.datasource = datasource; this.cache = cache; this.mapper = mapper; } @Override public void getDashboard(final Callback callback) { try { List<Image> result; if (cache.isValid()) { result = mapper.map(cache.get()); } else {
final List<ImageEntity> images = datasource.getDashboard();
txusballesteros/Android-Clean-Testing
app/src/androidTest/java/com/txusballesteros/testing/integration/api/DashboardApiIntegrationTest.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/integration/IntegrationTest.java // @RunWith(AndroidJUnit4.class) // public abstract class IntegrationTest { // @Before // public final void setup() { // onInitializeInjection(); // } // // protected abstract void onInitializeInjection(); // }
import org.junit.Test; import java.util.List; import javax.inject.Inject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import android.test.suitebuilder.annotation.LargeTest; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.integration.IntegrationTest; import com.txusballesteros.testing.integration.internal.di.DaggerIntegrationTestComponent;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.integration.api; @LargeTest public class DashboardApiIntegrationTest extends IntegrationTest {
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/integration/IntegrationTest.java // @RunWith(AndroidJUnit4.class) // public abstract class IntegrationTest { // @Before // public final void setup() { // onInitializeInjection(); // } // // protected abstract void onInitializeInjection(); // } // Path: app/src/androidTest/java/com/txusballesteros/testing/integration/api/DashboardApiIntegrationTest.java import org.junit.Test; import java.util.List; import javax.inject.Inject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import android.test.suitebuilder.annotation.LargeTest; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.integration.IntegrationTest; import com.txusballesteros.testing.integration.internal.di.DaggerIntegrationTestComponent; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.integration.api; @LargeTest public class DashboardApiIntegrationTest extends IntegrationTest {
@Inject DashboardApi api;
txusballesteros/Android-Clean-Testing
app/src/androidTest/java/com/txusballesteros/testing/integration/api/DashboardApiIntegrationTest.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/integration/IntegrationTest.java // @RunWith(AndroidJUnit4.class) // public abstract class IntegrationTest { // @Before // public final void setup() { // onInitializeInjection(); // } // // protected abstract void onInitializeInjection(); // }
import org.junit.Test; import java.util.List; import javax.inject.Inject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import android.test.suitebuilder.annotation.LargeTest; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.integration.IntegrationTest; import com.txusballesteros.testing.integration.internal.di.DaggerIntegrationTestComponent;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.integration.api; @LargeTest public class DashboardApiIntegrationTest extends IntegrationTest { @Inject DashboardApi api; @Override protected void onInitializeInjection() { DaggerIntegrationTestComponent.builder() .build() .inject(this); } @Test public void shouldGetDashboard() {
// Path: app/src/main/java/com/txusballesteros/testing/data/api/DashboardApi.java // public interface DashboardApi { // List<ImageResponse> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponse.java // public class ImageResponse { // private Uri url; // // private ImageResponse() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageResponse image; // // public Builder() { // this.image = new ImageResponse(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageResponse build() { // return image; // } // } // } // // Path: app/src/androidTest/java/com/txusballesteros/testing/integration/IntegrationTest.java // @RunWith(AndroidJUnit4.class) // public abstract class IntegrationTest { // @Before // public final void setup() { // onInitializeInjection(); // } // // protected abstract void onInitializeInjection(); // } // Path: app/src/androidTest/java/com/txusballesteros/testing/integration/api/DashboardApiIntegrationTest.java import org.junit.Test; import java.util.List; import javax.inject.Inject; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import android.test.suitebuilder.annotation.LargeTest; import com.txusballesteros.testing.data.api.DashboardApi; import com.txusballesteros.testing.data.api.model.ImageResponse; import com.txusballesteros.testing.integration.IntegrationTest; import com.txusballesteros.testing.integration.internal.di.DaggerIntegrationTestComponent; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.integration.api; @LargeTest public class DashboardApiIntegrationTest extends IntegrationTest { @Inject DashboardApi api; @Override protected void onInitializeInjection() { DaggerIntegrationTestComponent.builder() .build() .inject(this); } @Test public void shouldGetDashboard() {
final List<ImageResponse> response = api.getDashboard();
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/domain/usecase/internal/di/UseCasesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/domain/interactor/GetDashboardInteractor.java // public class GetDashboardInteractor extends AbsInteractor implements GetDashboardUseCase, Runnable { // private final ThreadExecutor executor; // private final PostExecutionThread postExecution; // private final DashboardRepository repository; // private Callback callback; // // @Inject // public GetDashboardInteractor(ThreadExecutor executor, // PostExecutionThread postExecution, // DashboardRepository repository) { // this.executor = executor; // this.postExecution = postExecution; // this.repository = repository; // } // // @Override // public void execute(final Callback callback) { // this.callback = callback; // this.executor.execute(this); // } // // @Override // public void run() { // repository.getDashboard(new DashboardRepository.Callback() { // @Override // public void onSuccess(final List<Image> images) { // notifyOnSuccess(images); // } // // @Override // public void onError() { // notifyOnError(); // } // }); // } // // private void notifyOnSuccess(final List<Image> images) { // postExecution.post(new Runnable() { // @Override // public void run() { // callback.onDashboardReady(images); // } // }); // } // // protected void notifyOnError() { // postExecution.post(new Runnable() { // @Override // public void run() { // callback.onError(); // } // }); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // }
import com.txusballesteros.testing.domain.interactor.GetDashboardInteractor; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import dagger.Module; import dagger.Provides;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.domain.usecase.internal.di; @Module public class UseCasesModule { @Provides
// Path: app/src/main/java/com/txusballesteros/testing/domain/interactor/GetDashboardInteractor.java // public class GetDashboardInteractor extends AbsInteractor implements GetDashboardUseCase, Runnable { // private final ThreadExecutor executor; // private final PostExecutionThread postExecution; // private final DashboardRepository repository; // private Callback callback; // // @Inject // public GetDashboardInteractor(ThreadExecutor executor, // PostExecutionThread postExecution, // DashboardRepository repository) { // this.executor = executor; // this.postExecution = postExecution; // this.repository = repository; // } // // @Override // public void execute(final Callback callback) { // this.callback = callback; // this.executor.execute(this); // } // // @Override // public void run() { // repository.getDashboard(new DashboardRepository.Callback() { // @Override // public void onSuccess(final List<Image> images) { // notifyOnSuccess(images); // } // // @Override // public void onError() { // notifyOnError(); // } // }); // } // // private void notifyOnSuccess(final List<Image> images) { // postExecution.post(new Runnable() { // @Override // public void run() { // callback.onDashboardReady(images); // } // }); // } // // protected void notifyOnError() { // postExecution.post(new Runnable() { // @Override // public void run() { // callback.onError(); // } // }); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/internal/di/UseCasesModule.java import com.txusballesteros.testing.domain.interactor.GetDashboardInteractor; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import dagger.Module; import dagger.Provides; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.domain.usecase.internal.di; @Module public class UseCasesModule { @Provides
GetDashboardUseCase provideGetUseCase(GetDashboardInteractor interactor) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/domain/usecase/internal/di/UseCasesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/domain/interactor/GetDashboardInteractor.java // public class GetDashboardInteractor extends AbsInteractor implements GetDashboardUseCase, Runnable { // private final ThreadExecutor executor; // private final PostExecutionThread postExecution; // private final DashboardRepository repository; // private Callback callback; // // @Inject // public GetDashboardInteractor(ThreadExecutor executor, // PostExecutionThread postExecution, // DashboardRepository repository) { // this.executor = executor; // this.postExecution = postExecution; // this.repository = repository; // } // // @Override // public void execute(final Callback callback) { // this.callback = callback; // this.executor.execute(this); // } // // @Override // public void run() { // repository.getDashboard(new DashboardRepository.Callback() { // @Override // public void onSuccess(final List<Image> images) { // notifyOnSuccess(images); // } // // @Override // public void onError() { // notifyOnError(); // } // }); // } // // private void notifyOnSuccess(final List<Image> images) { // postExecution.post(new Runnable() { // @Override // public void run() { // callback.onDashboardReady(images); // } // }); // } // // protected void notifyOnError() { // postExecution.post(new Runnable() { // @Override // public void run() { // callback.onError(); // } // }); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // }
import com.txusballesteros.testing.domain.interactor.GetDashboardInteractor; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import dagger.Module; import dagger.Provides;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.domain.usecase.internal.di; @Module public class UseCasesModule { @Provides
// Path: app/src/main/java/com/txusballesteros/testing/domain/interactor/GetDashboardInteractor.java // public class GetDashboardInteractor extends AbsInteractor implements GetDashboardUseCase, Runnable { // private final ThreadExecutor executor; // private final PostExecutionThread postExecution; // private final DashboardRepository repository; // private Callback callback; // // @Inject // public GetDashboardInteractor(ThreadExecutor executor, // PostExecutionThread postExecution, // DashboardRepository repository) { // this.executor = executor; // this.postExecution = postExecution; // this.repository = repository; // } // // @Override // public void execute(final Callback callback) { // this.callback = callback; // this.executor.execute(this); // } // // @Override // public void run() { // repository.getDashboard(new DashboardRepository.Callback() { // @Override // public void onSuccess(final List<Image> images) { // notifyOnSuccess(images); // } // // @Override // public void onError() { // notifyOnError(); // } // }); // } // // private void notifyOnSuccess(final List<Image> images) { // postExecution.post(new Runnable() { // @Override // public void run() { // callback.onDashboardReady(images); // } // }); // } // // protected void notifyOnError() { // postExecution.post(new Runnable() { // @Override // public void run() { // callback.onError(); // } // }); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/internal/di/UseCasesModule.java import com.txusballesteros.testing.domain.interactor.GetDashboardInteractor; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import dagger.Module; import dagger.Provides; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.domain.usecase.internal.di; @Module public class UseCasesModule { @Provides
GetDashboardUseCase provideGetUseCase(GetDashboardInteractor interactor) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationComponent.java
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // }
import com.txusballesteros.testing.Application; import javax.inject.Singleton; import dagger.Component;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; @Singleton @Component(modules = RuntimeApplicationModule.class) public interface RuntimeApplicationComponent extends ApplicationComponent {
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // Path: app/src/main/java/com/txusballesteros/testing/internal/di/RuntimeApplicationComponent.java import com.txusballesteros.testing.Application; import javax.inject.Singleton; import dagger.Component; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; @Singleton @Component(modules = RuntimeApplicationModule.class) public interface RuntimeApplicationComponent extends ApplicationComponent {
void inject(Application application);
txusballesteros/Android-Clean-Testing
app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationComponent.java
// Path: app/src/androidTest/java/com/txusballesteros/testing/TestingApplication.java // public class TestingApplication extends Application { // private TestingApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerTestingApplicationComponent // .builder() // .testingApplicationModule(new TestingApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // @Override // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // @Override // public DependenciesInjector getDependenciesInjector() { // return injector; // } // }
import com.txusballesteros.testing.TestingApplication; import javax.inject.Singleton; import dagger.Component;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; @Singleton @Component(modules = TestingApplicationModule.class) public interface TestingApplicationComponent extends ApplicationComponent {
// Path: app/src/androidTest/java/com/txusballesteros/testing/TestingApplication.java // public class TestingApplication extends Application { // private TestingApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerTestingApplicationComponent // .builder() // .testingApplicationModule(new TestingApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // @Override // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // @Override // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // Path: app/src/androidTest/java/com/txusballesteros/testing/internal/di/TestingApplicationComponent.java import com.txusballesteros.testing.TestingApplication; import javax.inject.Singleton; import dagger.Component; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; @Singleton @Component(modules = TestingApplicationModule.class) public interface TestingApplicationComponent extends ApplicationComponent {
void inject(TestingApplication application);
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/endpoint/internal/di/EndpointsModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/DashboardEndpoint.java // public interface DashboardEndpoint { // @GET("v1/gifs/trending") // Call<DashboardListEndpointResponse> getDashboard(@Query("api_key") String apiKey); // }
import retrofit2.GsonConverterFactory; import retrofit2.Retrofit; import com.txusballesteros.testing.data.api.endpoint.DashboardEndpoint; import javax.inject.Singleton; import dagger.Module; import dagger.Provides;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.endpoint.internal.di; @Module public class EndpointsModule { private static final String BASE_URL = "http://api.giphy.com/"; @Provides @Singleton
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/DashboardEndpoint.java // public interface DashboardEndpoint { // @GET("v1/gifs/trending") // Call<DashboardListEndpointResponse> getDashboard(@Query("api_key") String apiKey); // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/internal/di/EndpointsModule.java import retrofit2.GsonConverterFactory; import retrofit2.Retrofit; import com.txusballesteros.testing.data.api.endpoint.DashboardEndpoint; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.endpoint.internal.di; @Module public class EndpointsModule { private static final String BASE_URL = "http://api.giphy.com/"; @Provides @Singleton
DashboardEndpoint provideDashboardEndpoint() {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/datasource/internal/di/DatasourcesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java // public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { // private final DashboardApi api; // private final ImageResponseMapper mapper; // // @Inject // public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { // this.api = api; // this.mapper = mapper; // } // // @Override // public List<ImageEntity> getDashboard() { // final List<ImageResponse> images = api.getDashboard(); // return mapper.map(images); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java // public class ImageEntityMapperImpl implements ImageEntityMapper { // @Inject // public ImageEntityMapperImpl() { } // // @Override // public List<Image> map(List<ImageEntity> source) { // List<Image> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final Image image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public Image map(ImageEntity source) { // return new Image.Builder() // .setUrl(source.getUrl()) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.datasource.DashboardCloudDatasource; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.internal.di; @Module public class DatasourcesModule { @Provides
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java // public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { // private final DashboardApi api; // private final ImageResponseMapper mapper; // // @Inject // public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { // this.api = api; // this.mapper = mapper; // } // // @Override // public List<ImageEntity> getDashboard() { // final List<ImageResponse> images = api.getDashboard(); // return mapper.map(images); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java // public class ImageEntityMapperImpl implements ImageEntityMapper { // @Inject // public ImageEntityMapperImpl() { } // // @Override // public List<Image> map(List<ImageEntity> source) { // List<Image> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final Image image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public Image map(ImageEntity source) { // return new Image.Builder() // .setUrl(source.getUrl()) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/internal/di/DatasourcesModule.java import dagger.Provides; import com.txusballesteros.testing.data.datasource.DashboardCloudDatasource; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.internal.di; @Module public class DatasourcesModule { @Provides
DashboardDatasource provideDashboardDatasource(DashboardCloudDatasource datasource) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/datasource/internal/di/DatasourcesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java // public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { // private final DashboardApi api; // private final ImageResponseMapper mapper; // // @Inject // public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { // this.api = api; // this.mapper = mapper; // } // // @Override // public List<ImageEntity> getDashboard() { // final List<ImageResponse> images = api.getDashboard(); // return mapper.map(images); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java // public class ImageEntityMapperImpl implements ImageEntityMapper { // @Inject // public ImageEntityMapperImpl() { } // // @Override // public List<Image> map(List<ImageEntity> source) { // List<Image> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final Image image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public Image map(ImageEntity source) { // return new Image.Builder() // .setUrl(source.getUrl()) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.datasource.DashboardCloudDatasource; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.internal.di; @Module public class DatasourcesModule { @Provides
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java // public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { // private final DashboardApi api; // private final ImageResponseMapper mapper; // // @Inject // public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { // this.api = api; // this.mapper = mapper; // } // // @Override // public List<ImageEntity> getDashboard() { // final List<ImageResponse> images = api.getDashboard(); // return mapper.map(images); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java // public class ImageEntityMapperImpl implements ImageEntityMapper { // @Inject // public ImageEntityMapperImpl() { } // // @Override // public List<Image> map(List<ImageEntity> source) { // List<Image> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final Image image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public Image map(ImageEntity source) { // return new Image.Builder() // .setUrl(source.getUrl()) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/internal/di/DatasourcesModule.java import dagger.Provides; import com.txusballesteros.testing.data.datasource.DashboardCloudDatasource; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.internal.di; @Module public class DatasourcesModule { @Provides
DashboardDatasource provideDashboardDatasource(DashboardCloudDatasource datasource) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/datasource/internal/di/DatasourcesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java // public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { // private final DashboardApi api; // private final ImageResponseMapper mapper; // // @Inject // public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { // this.api = api; // this.mapper = mapper; // } // // @Override // public List<ImageEntity> getDashboard() { // final List<ImageResponse> images = api.getDashboard(); // return mapper.map(images); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java // public class ImageEntityMapperImpl implements ImageEntityMapper { // @Inject // public ImageEntityMapperImpl() { } // // @Override // public List<Image> map(List<ImageEntity> source) { // List<Image> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final Image image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public Image map(ImageEntity source) { // return new Image.Builder() // .setUrl(source.getUrl()) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.datasource.DashboardCloudDatasource; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.internal.di; @Module public class DatasourcesModule { @Provides DashboardDatasource provideDashboardDatasource(DashboardCloudDatasource datasource) { return datasource; } @Provides
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java // public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { // private final DashboardApi api; // private final ImageResponseMapper mapper; // // @Inject // public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { // this.api = api; // this.mapper = mapper; // } // // @Override // public List<ImageEntity> getDashboard() { // final List<ImageResponse> images = api.getDashboard(); // return mapper.map(images); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java // public class ImageEntityMapperImpl implements ImageEntityMapper { // @Inject // public ImageEntityMapperImpl() { } // // @Override // public List<Image> map(List<ImageEntity> source) { // List<Image> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final Image image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public Image map(ImageEntity source) { // return new Image.Builder() // .setUrl(source.getUrl()) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/internal/di/DatasourcesModule.java import dagger.Provides; import com.txusballesteros.testing.data.datasource.DashboardCloudDatasource; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.internal.di; @Module public class DatasourcesModule { @Provides DashboardDatasource provideDashboardDatasource(DashboardCloudDatasource datasource) { return datasource; } @Provides
ImageEntityMapper provideImageEntityMapper(ImageEntityMapperImpl mapper) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/datasource/internal/di/DatasourcesModule.java
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java // public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { // private final DashboardApi api; // private final ImageResponseMapper mapper; // // @Inject // public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { // this.api = api; // this.mapper = mapper; // } // // @Override // public List<ImageEntity> getDashboard() { // final List<ImageResponse> images = api.getDashboard(); // return mapper.map(images); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java // public class ImageEntityMapperImpl implements ImageEntityMapper { // @Inject // public ImageEntityMapperImpl() { } // // @Override // public List<Image> map(List<ImageEntity> source) { // List<Image> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final Image image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public Image map(ImageEntity source) { // return new Image.Builder() // .setUrl(source.getUrl()) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.data.datasource.DashboardCloudDatasource; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.internal.di; @Module public class DatasourcesModule { @Provides DashboardDatasource provideDashboardDatasource(DashboardCloudDatasource datasource) { return datasource; } @Provides
// Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardCloudDatasource.java // public class DashboardCloudDatasource extends AbsDatasource implements DashboardDatasource { // private final DashboardApi api; // private final ImageResponseMapper mapper; // // @Inject // public DashboardCloudDatasource(DashboardApi api, ImageResponseMapper mapper) { // this.api = api; // this.mapper = mapper; // } // // @Override // public List<ImageEntity> getDashboard() { // final List<ImageResponse> images = api.getDashboard(); // return mapper.map(images); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/DashboardDatasource.java // public interface DashboardDatasource { // List<ImageEntity> getDashboard(); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapper.java // public interface ImageEntityMapper { // List<Image> map(List<ImageEntity> source); // Image map(ImageEntity source); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java // public class ImageEntityMapperImpl implements ImageEntityMapper { // @Inject // public ImageEntityMapperImpl() { } // // @Override // public List<Image> map(List<ImageEntity> source) { // List<Image> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final Image image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public Image map(ImageEntity source) { // return new Image.Builder() // .setUrl(source.getUrl()) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/internal/di/DatasourcesModule.java import dagger.Provides; import com.txusballesteros.testing.data.datasource.DashboardCloudDatasource; import com.txusballesteros.testing.data.datasource.DashboardDatasource; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapper; import com.txusballesteros.testing.data.datasource.model.ImageEntityMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.internal.di; @Module public class DatasourcesModule { @Provides DashboardDatasource provideDashboardDatasource(DashboardCloudDatasource datasource) { return datasource; } @Provides
ImageEntityMapper provideImageEntityMapper(ImageEntityMapperImpl mapper) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/view/DashboardListAdapter.java
// Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // }
import com.txusballesteros.testing.R; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.view.instrumentation.ImageLoader; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view; public class DashboardListAdapter extends RecyclerView.Adapter<DashboardListAdapter.ViewHolder> { private final List<ImageModel> dataset; private final Context context;
// Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModel.java // public class ImageModel { // private Uri url; // // private ImageModel() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageModel image; // // public Builder() { // this.image = new ImageModel(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageModel build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // } // Path: app/src/main/java/com/txusballesteros/testing/view/DashboardListAdapter.java import com.txusballesteros.testing.R; import com.txusballesteros.testing.presentation.model.ImageModel; import com.txusballesteros.testing.view.instrumentation.ImageLoader; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.view; public class DashboardListAdapter extends RecyclerView.Adapter<DashboardListAdapter.ViewHolder> { private final List<ImageModel> dataset; private final Context context;
private final ImageLoader imageLoader;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.model; public interface ImageResponseMapper { List<ImageResponse> map(DashboardListEndpointResponse source);
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.model; public interface ImageResponseMapper { List<ImageResponse> map(DashboardListEndpointResponse source);
List<ImageEntity> map(List<ImageResponse> source);
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.model; public interface ImageResponseMapper { List<ImageResponse> map(DashboardListEndpointResponse source); List<ImageEntity> map(List<ImageResponse> source); ImageEntity map(ImageResponse source);
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapper.java import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.datasource.model.ImageEntity; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.model; public interface ImageResponseMapper { List<ImageResponse> map(DashboardListEndpointResponse source); List<ImageEntity> map(List<ImageResponse> source); ImageEntity map(ImageResponse source);
ImageResponse map(DashboardEndpointResponse source);
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/presentation/internal/di/PresentationModule.java
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java // public class MainPresenterImpl implements MainPresenter { // private final View view; // private final GetDashboardUseCase interactor; // private final ImageModelMapper mapper; // // @Inject // public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { // this.view = view; // this.interactor = interactor; // this.mapper = mapper; // } // // @Override // public void onStart() { // interactor.execute(new GetDashboardUseCase.Callback() { // @Override // public void onDashboardReady(List<Image> images) { // view.renderDashboard(mapper.map(images)); // } // // @Override // public void onError() { // view.renderError(); // } // }); // } // // @Override // public void onStop() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java // public class ImageModelMapperImpl implements ImageModelMapper { // @Inject // public ImageModelMapperImpl() { } // // @Override // public List<ImageModel> map(List<Image> source) { // List<ImageModel> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageModel image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageModel map(Image source) { // return new ImageModel.Builder() // .setUrl(source.getUrl()) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.presentation.MainPresenter; import com.txusballesteros.testing.presentation.MainPresenterImpl; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import com.txusballesteros.testing.presentation.model.ImageModelMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.internal.di; @Module public class PresentationModule { @Provides
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java // public class MainPresenterImpl implements MainPresenter { // private final View view; // private final GetDashboardUseCase interactor; // private final ImageModelMapper mapper; // // @Inject // public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { // this.view = view; // this.interactor = interactor; // this.mapper = mapper; // } // // @Override // public void onStart() { // interactor.execute(new GetDashboardUseCase.Callback() { // @Override // public void onDashboardReady(List<Image> images) { // view.renderDashboard(mapper.map(images)); // } // // @Override // public void onError() { // view.renderError(); // } // }); // } // // @Override // public void onStop() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java // public class ImageModelMapperImpl implements ImageModelMapper { // @Inject // public ImageModelMapperImpl() { } // // @Override // public List<ImageModel> map(List<Image> source) { // List<ImageModel> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageModel image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageModel map(Image source) { // return new ImageModel.Builder() // .setUrl(source.getUrl()) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/presentation/internal/di/PresentationModule.java import dagger.Provides; import com.txusballesteros.testing.presentation.MainPresenter; import com.txusballesteros.testing.presentation.MainPresenterImpl; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import com.txusballesteros.testing.presentation.model.ImageModelMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.internal.di; @Module public class PresentationModule { @Provides
MainPresenter provideMainPresenter(MainPresenterImpl presenter) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/presentation/internal/di/PresentationModule.java
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java // public class MainPresenterImpl implements MainPresenter { // private final View view; // private final GetDashboardUseCase interactor; // private final ImageModelMapper mapper; // // @Inject // public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { // this.view = view; // this.interactor = interactor; // this.mapper = mapper; // } // // @Override // public void onStart() { // interactor.execute(new GetDashboardUseCase.Callback() { // @Override // public void onDashboardReady(List<Image> images) { // view.renderDashboard(mapper.map(images)); // } // // @Override // public void onError() { // view.renderError(); // } // }); // } // // @Override // public void onStop() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java // public class ImageModelMapperImpl implements ImageModelMapper { // @Inject // public ImageModelMapperImpl() { } // // @Override // public List<ImageModel> map(List<Image> source) { // List<ImageModel> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageModel image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageModel map(Image source) { // return new ImageModel.Builder() // .setUrl(source.getUrl()) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.presentation.MainPresenter; import com.txusballesteros.testing.presentation.MainPresenterImpl; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import com.txusballesteros.testing.presentation.model.ImageModelMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.internal.di; @Module public class PresentationModule { @Provides
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java // public class MainPresenterImpl implements MainPresenter { // private final View view; // private final GetDashboardUseCase interactor; // private final ImageModelMapper mapper; // // @Inject // public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { // this.view = view; // this.interactor = interactor; // this.mapper = mapper; // } // // @Override // public void onStart() { // interactor.execute(new GetDashboardUseCase.Callback() { // @Override // public void onDashboardReady(List<Image> images) { // view.renderDashboard(mapper.map(images)); // } // // @Override // public void onError() { // view.renderError(); // } // }); // } // // @Override // public void onStop() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java // public class ImageModelMapperImpl implements ImageModelMapper { // @Inject // public ImageModelMapperImpl() { } // // @Override // public List<ImageModel> map(List<Image> source) { // List<ImageModel> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageModel image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageModel map(Image source) { // return new ImageModel.Builder() // .setUrl(source.getUrl()) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/presentation/internal/di/PresentationModule.java import dagger.Provides; import com.txusballesteros.testing.presentation.MainPresenter; import com.txusballesteros.testing.presentation.MainPresenterImpl; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import com.txusballesteros.testing.presentation.model.ImageModelMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.internal.di; @Module public class PresentationModule { @Provides
MainPresenter provideMainPresenter(MainPresenterImpl presenter) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/presentation/internal/di/PresentationModule.java
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java // public class MainPresenterImpl implements MainPresenter { // private final View view; // private final GetDashboardUseCase interactor; // private final ImageModelMapper mapper; // // @Inject // public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { // this.view = view; // this.interactor = interactor; // this.mapper = mapper; // } // // @Override // public void onStart() { // interactor.execute(new GetDashboardUseCase.Callback() { // @Override // public void onDashboardReady(List<Image> images) { // view.renderDashboard(mapper.map(images)); // } // // @Override // public void onError() { // view.renderError(); // } // }); // } // // @Override // public void onStop() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java // public class ImageModelMapperImpl implements ImageModelMapper { // @Inject // public ImageModelMapperImpl() { } // // @Override // public List<ImageModel> map(List<Image> source) { // List<ImageModel> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageModel image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageModel map(Image source) { // return new ImageModel.Builder() // .setUrl(source.getUrl()) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.presentation.MainPresenter; import com.txusballesteros.testing.presentation.MainPresenterImpl; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import com.txusballesteros.testing.presentation.model.ImageModelMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.internal.di; @Module public class PresentationModule { @Provides MainPresenter provideMainPresenter(MainPresenterImpl presenter) { return presenter; } @Provides
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java // public class MainPresenterImpl implements MainPresenter { // private final View view; // private final GetDashboardUseCase interactor; // private final ImageModelMapper mapper; // // @Inject // public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { // this.view = view; // this.interactor = interactor; // this.mapper = mapper; // } // // @Override // public void onStart() { // interactor.execute(new GetDashboardUseCase.Callback() { // @Override // public void onDashboardReady(List<Image> images) { // view.renderDashboard(mapper.map(images)); // } // // @Override // public void onError() { // view.renderError(); // } // }); // } // // @Override // public void onStop() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java // public class ImageModelMapperImpl implements ImageModelMapper { // @Inject // public ImageModelMapperImpl() { } // // @Override // public List<ImageModel> map(List<Image> source) { // List<ImageModel> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageModel image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageModel map(Image source) { // return new ImageModel.Builder() // .setUrl(source.getUrl()) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/presentation/internal/di/PresentationModule.java import dagger.Provides; import com.txusballesteros.testing.presentation.MainPresenter; import com.txusballesteros.testing.presentation.MainPresenterImpl; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import com.txusballesteros.testing.presentation.model.ImageModelMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.internal.di; @Module public class PresentationModule { @Provides MainPresenter provideMainPresenter(MainPresenterImpl presenter) { return presenter; } @Provides
ImageModelMapper provideImageModelMapper(ImageModelMapperImpl mapper) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/presentation/internal/di/PresentationModule.java
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java // public class MainPresenterImpl implements MainPresenter { // private final View view; // private final GetDashboardUseCase interactor; // private final ImageModelMapper mapper; // // @Inject // public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { // this.view = view; // this.interactor = interactor; // this.mapper = mapper; // } // // @Override // public void onStart() { // interactor.execute(new GetDashboardUseCase.Callback() { // @Override // public void onDashboardReady(List<Image> images) { // view.renderDashboard(mapper.map(images)); // } // // @Override // public void onError() { // view.renderError(); // } // }); // } // // @Override // public void onStop() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java // public class ImageModelMapperImpl implements ImageModelMapper { // @Inject // public ImageModelMapperImpl() { } // // @Override // public List<ImageModel> map(List<Image> source) { // List<ImageModel> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageModel image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageModel map(Image source) { // return new ImageModel.Builder() // .setUrl(source.getUrl()) // .build(); // } // }
import dagger.Provides; import com.txusballesteros.testing.presentation.MainPresenter; import com.txusballesteros.testing.presentation.MainPresenterImpl; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import com.txusballesteros.testing.presentation.model.ImageModelMapperImpl; import dagger.Module;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.internal.di; @Module public class PresentationModule { @Provides MainPresenter provideMainPresenter(MainPresenterImpl presenter) { return presenter; } @Provides
// Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenter.java // public interface MainPresenter { // void onStart(); // void onStop(); // // interface View { // void renderDashboard(List<ImageModel> images); // void renderError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java // public class MainPresenterImpl implements MainPresenter { // private final View view; // private final GetDashboardUseCase interactor; // private final ImageModelMapper mapper; // // @Inject // public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { // this.view = view; // this.interactor = interactor; // this.mapper = mapper; // } // // @Override // public void onStart() { // interactor.execute(new GetDashboardUseCase.Callback() { // @Override // public void onDashboardReady(List<Image> images) { // view.renderDashboard(mapper.map(images)); // } // // @Override // public void onError() { // view.renderError(); // } // }); // } // // @Override // public void onStop() { } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java // public class ImageModelMapperImpl implements ImageModelMapper { // @Inject // public ImageModelMapperImpl() { } // // @Override // public List<ImageModel> map(List<Image> source) { // List<ImageModel> result = new ArrayList<>(source.size()); // for (int location = 0; location < source.size(); location++) { // final ImageModel image = map(source.get(location)); // result.add(image); // } // return result; // } // // @Override // public ImageModel map(Image source) { // return new ImageModel.Builder() // .setUrl(source.getUrl()) // .build(); // } // } // Path: app/src/main/java/com/txusballesteros/testing/presentation/internal/di/PresentationModule.java import dagger.Provides; import com.txusballesteros.testing.presentation.MainPresenter; import com.txusballesteros.testing.presentation.MainPresenterImpl; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import com.txusballesteros.testing.presentation.model.ImageModelMapperImpl; import dagger.Module; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.internal.di; @Module public class PresentationModule { @Provides MainPresenter provideMainPresenter(MainPresenterImpl presenter) { return presenter; } @Provides
ImageModelMapper provideImageModelMapper(ImageModelMapperImpl mapper) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // }
import com.txusballesteros.testing.domain.model.Image; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.domain.usecase; public interface GetDashboardUseCase { void execute(final Callback callback); interface Callback {
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java import com.txusballesteros.testing.domain.model.Image; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.domain.usecase; public interface GetDashboardUseCase { void execute(final Callback callback); interface Callback {
void onDashboardReady(List<Image> images);
txusballesteros/Android-Clean-Testing
app/src/test/java/com/txusballesteros/testing/presentation/model/ImageModelMapperUnitTest.java
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // }
import org.mockito.Mock; import java.util.Iterator; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import android.net.Uri; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import org.junit.Test;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.model; public class ImageModelMapperUnitTest extends UnitTest { private final static Uri TESTING_IMAGE_URL = Uri.parse("http://developer.android.com");
// Path: app/src/test/java/com/txusballesteros/testing/UnitTest.java // @RunWith(JUnit4.class) // @SmallTest // public abstract class UnitTest { // @Before // public final void setup() { // initializeMocks(); // onSetup(); // } // // private void initializeMocks() { // MockitoAnnotations.initMocks(this); // } // // protected abstract void onSetup(); // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // Path: app/src/test/java/com/txusballesteros/testing/presentation/model/ImageModelMapperUnitTest.java import org.mockito.Mock; import java.util.Iterator; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import android.net.Uri; import com.txusballesteros.testing.UnitTest; import com.txusballesteros.testing.domain.model.Image; import org.junit.Test; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.model; public class ImageModelMapperUnitTest extends UnitTest { private final static Uri TESTING_IMAGE_URL = Uri.parse("http://developer.android.com");
@Mock Image imageMock;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // }
import javax.inject.Inject; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterImpl implements MainPresenter { private final View view;
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java import javax.inject.Inject; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterImpl implements MainPresenter { private final View view;
private final GetDashboardUseCase interactor;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // }
import javax.inject.Inject; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterImpl implements MainPresenter { private final View view; private final GetDashboardUseCase interactor;
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java import javax.inject.Inject; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterImpl implements MainPresenter { private final View view; private final GetDashboardUseCase interactor;
private final ImageModelMapper mapper;
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // }
import javax.inject.Inject; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import java.util.List;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterImpl implements MainPresenter { private final View view; private final GetDashboardUseCase interactor; private final ImageModelMapper mapper; @Inject public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { this.view = view; this.interactor = interactor; this.mapper = mapper; } @Override public void onStart() { interactor.execute(new GetDashboardUseCase.Callback() { @Override
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/usecase/GetDashboardUseCase.java // public interface GetDashboardUseCase { // void execute(final Callback callback); // // interface Callback { // void onDashboardReady(List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapper.java // public interface ImageModelMapper { // List<ImageModel> map(List<Image> source); // ImageModel map(Image source); // } // Path: app/src/main/java/com/txusballesteros/testing/presentation/MainPresenterImpl.java import javax.inject.Inject; import com.txusballesteros.testing.domain.model.Image; import com.txusballesteros.testing.domain.usecase.GetDashboardUseCase; import com.txusballesteros.testing.presentation.model.ImageModelMapper; import java.util.List; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation; public class MainPresenterImpl implements MainPresenter { private final View view; private final GetDashboardUseCase interactor; private final ImageModelMapper mapper; @Inject public MainPresenterImpl(View view, GetDashboardUseCase interactor, ImageModelMapper mapper) { this.view = view; this.interactor = interactor; this.mapper = mapper; } @Override public void onStart() { interactor.execute(new GetDashboardUseCase.Callback() { @Override
public void onDashboardReady(List<Image> images) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // }
import com.txusballesteros.testing.domain.model.Image; import java.util.ArrayList; import java.util.List; import javax.inject.Inject;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.model; public class ImageModelMapperImpl implements ImageModelMapper { @Inject public ImageModelMapperImpl() { } @Override
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/presentation/model/ImageModelMapperImpl.java import com.txusballesteros.testing.domain.model.Image; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.presentation.model; public class ImageModelMapperImpl implements ImageModelMapper { @Inject public ImageModelMapperImpl() { } @Override
public List<ImageModel> map(List<Image> source) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import android.net.Uri; import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import com.txusballesteros.testing.data.datasource.model.ImageEntity;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.model; public class ImageResponseMapperImpl implements ImageResponseMapper { private final ImageUriTransformer imageUriTransformer; @Inject public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { this.imageUriTransformer = imageUriTransformer; } @Override
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import android.net.Uri; import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import com.txusballesteros.testing.data.datasource.model.ImageEntity; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.model; public class ImageResponseMapperImpl implements ImageResponseMapper { private final ImageUriTransformer imageUriTransformer; @Inject public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { this.imageUriTransformer = imageUriTransformer; } @Override
public List<ImageResponse> map(DashboardListEndpointResponse source) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import android.net.Uri; import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import com.txusballesteros.testing.data.datasource.model.ImageEntity;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.model; public class ImageResponseMapperImpl implements ImageResponseMapper { private final ImageUriTransformer imageUriTransformer; @Inject public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { this.imageUriTransformer = imageUriTransformer; } @Override public List<ImageResponse> map(DashboardListEndpointResponse source) { List<ImageResponse> result = new ArrayList<>(source.data.size()); for (int location = 0; location < source.data.size(); location++) { final ImageResponse image = map(source.data.get(location)); result.add(image); } return result; } @Override
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import android.net.Uri; import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import com.txusballesteros.testing.data.datasource.model.ImageEntity; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.api.model; public class ImageResponseMapperImpl implements ImageResponseMapper { private final ImageUriTransformer imageUriTransformer; @Inject public ImageResponseMapperImpl(ImageUriTransformer imageUriTransformer) { this.imageUriTransformer = imageUriTransformer; } @Override public List<ImageResponse> map(DashboardListEndpointResponse source) { List<ImageResponse> result = new ArrayList<>(source.data.size()); for (int location = 0; location < source.data.size(); location++) { final ImageResponse image = map(source.data.get(location)); result.add(image); } return result; } @Override
public List<ImageEntity> map(List<ImageResponse> source) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // }
import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import android.net.Uri; import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import com.txusballesteros.testing.data.datasource.model.ImageEntity;
} @Override public List<ImageResponse> map(DashboardListEndpointResponse source) { List<ImageResponse> result = new ArrayList<>(source.data.size()); for (int location = 0; location < source.data.size(); location++) { final ImageResponse image = map(source.data.get(location)); result.add(image); } return result; } @Override public List<ImageEntity> map(List<ImageResponse> source) { List<ImageEntity> result = new ArrayList<>(source.size()); for (int location = 0; location < source.size(); location++) { final ImageEntity image = map(source.get(location)); result.add(image); } return result; } @Override public ImageEntity map(ImageResponse source) { return new ImageEntity.Builder() .setUrl(source.getUrl()) .build(); } @Override
// Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardEndpointResponse.java // public class DashboardEndpointResponse { // public String id; // public String embed_url; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/endpoint/model/DashboardListEndpointResponse.java // public class DashboardListEndpointResponse { // public List<DashboardEndpointResponse> data; // } // // Path: app/src/main/java/com/txusballesteros/testing/data/api/transformer/ImageUriTransformer.java // public interface ImageUriTransformer { // String transform(String imageId); // } // // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntity.java // public class ImageEntity { // private Uri url; // // private ImageEntity() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private ImageEntity image; // // public Builder() { // this.image = new ImageEntity(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public ImageEntity build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/api/model/ImageResponseMapperImpl.java import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import android.net.Uri; import com.txusballesteros.testing.data.api.endpoint.model.DashboardEndpointResponse; import com.txusballesteros.testing.data.api.endpoint.model.DashboardListEndpointResponse; import com.txusballesteros.testing.data.api.transformer.ImageUriTransformer; import com.txusballesteros.testing.data.datasource.model.ImageEntity; } @Override public List<ImageResponse> map(DashboardListEndpointResponse source) { List<ImageResponse> result = new ArrayList<>(source.data.size()); for (int location = 0; location < source.data.size(); location++) { final ImageResponse image = map(source.data.get(location)); result.add(image); } return result; } @Override public List<ImageEntity> map(List<ImageResponse> source) { List<ImageEntity> result = new ArrayList<>(source.size()); for (int location = 0; location < source.size(); location++) { final ImageEntity image = map(source.get(location)); result.add(image); } return result; } @Override public ImageEntity map(ImageResponse source) { return new ImageEntity.Builder() .setUrl(source.getUrl()) .build(); } @Override
public ImageResponse map(DashboardEndpointResponse source) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // }
import com.txusballesteros.testing.domain.model.Image; import java.util.ArrayList; import java.util.List; import javax.inject.Inject;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.model; public class ImageEntityMapperImpl implements ImageEntityMapper { @Inject public ImageEntityMapperImpl() { } @Override
// Path: app/src/main/java/com/txusballesteros/testing/domain/model/Image.java // public class Image { // private Uri url; // // private Image() { } // // public Uri getUrl() { // return url; // } // // public static class Builder { // private Image image; // // public Builder() { // this.image = new Image(); // } // // public Builder setUrl(Uri url) { // image.url = url; // return this; // } // // public Image build() { // return image; // } // } // } // Path: app/src/main/java/com/txusballesteros/testing/data/datasource/model/ImageEntityMapperImpl.java import com.txusballesteros.testing.domain.model.Image; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.data.datasource.model; public class ImageEntityMapperImpl implements ImageEntityMapper { @Inject public ImageEntityMapperImpl() { } @Override
public List<Image> map(List<ImageEntity> source) {
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/PostExecutionThread.java // public interface PostExecutionThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/ThreadExecutor.java // public interface ThreadExecutor extends Executor { } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // }
import javax.inject.Singleton; import dagger.Component; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.domain.repository.DashboardRepository; import com.txusballesteros.testing.threading.PostExecutionThread; import com.txusballesteros.testing.threading.ThreadExecutor; import com.txusballesteros.testing.view.instrumentation.ImageLoader;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; public interface ApplicationComponent { Application getApplication();
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/PostExecutionThread.java // public interface PostExecutionThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/ThreadExecutor.java // public interface ThreadExecutor extends Executor { } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // } // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java import javax.inject.Singleton; import dagger.Component; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.domain.repository.DashboardRepository; import com.txusballesteros.testing.threading.PostExecutionThread; import com.txusballesteros.testing.threading.ThreadExecutor; import com.txusballesteros.testing.view.instrumentation.ImageLoader; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; public interface ApplicationComponent { Application getApplication();
ThreadExecutor getThreadExecutor();
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/PostExecutionThread.java // public interface PostExecutionThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/ThreadExecutor.java // public interface ThreadExecutor extends Executor { } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // }
import javax.inject.Singleton; import dagger.Component; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.domain.repository.DashboardRepository; import com.txusballesteros.testing.threading.PostExecutionThread; import com.txusballesteros.testing.threading.ThreadExecutor; import com.txusballesteros.testing.view.instrumentation.ImageLoader;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; public interface ApplicationComponent { Application getApplication(); ThreadExecutor getThreadExecutor();
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/PostExecutionThread.java // public interface PostExecutionThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/ThreadExecutor.java // public interface ThreadExecutor extends Executor { } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // } // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java import javax.inject.Singleton; import dagger.Component; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.domain.repository.DashboardRepository; import com.txusballesteros.testing.threading.PostExecutionThread; import com.txusballesteros.testing.threading.ThreadExecutor; import com.txusballesteros.testing.view.instrumentation.ImageLoader; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; public interface ApplicationComponent { Application getApplication(); ThreadExecutor getThreadExecutor();
PostExecutionThread getPostExecutionThread();
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/PostExecutionThread.java // public interface PostExecutionThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/ThreadExecutor.java // public interface ThreadExecutor extends Executor { } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // }
import javax.inject.Singleton; import dagger.Component; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.domain.repository.DashboardRepository; import com.txusballesteros.testing.threading.PostExecutionThread; import com.txusballesteros.testing.threading.ThreadExecutor; import com.txusballesteros.testing.view.instrumentation.ImageLoader;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; public interface ApplicationComponent { Application getApplication(); ThreadExecutor getThreadExecutor(); PostExecutionThread getPostExecutionThread();
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/PostExecutionThread.java // public interface PostExecutionThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/ThreadExecutor.java // public interface ThreadExecutor extends Executor { } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // } // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java import javax.inject.Singleton; import dagger.Component; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.domain.repository.DashboardRepository; import com.txusballesteros.testing.threading.PostExecutionThread; import com.txusballesteros.testing.threading.ThreadExecutor; import com.txusballesteros.testing.view.instrumentation.ImageLoader; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; public interface ApplicationComponent { Application getApplication(); ThreadExecutor getThreadExecutor(); PostExecutionThread getPostExecutionThread();
ImageLoader getImageLoader();
txusballesteros/Android-Clean-Testing
app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/PostExecutionThread.java // public interface PostExecutionThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/ThreadExecutor.java // public interface ThreadExecutor extends Executor { } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // }
import javax.inject.Singleton; import dagger.Component; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.domain.repository.DashboardRepository; import com.txusballesteros.testing.threading.PostExecutionThread; import com.txusballesteros.testing.threading.ThreadExecutor; import com.txusballesteros.testing.view.instrumentation.ImageLoader;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; public interface ApplicationComponent { Application getApplication(); ThreadExecutor getThreadExecutor(); PostExecutionThread getPostExecutionThread(); ImageLoader getImageLoader();
// Path: app/src/main/java/com/txusballesteros/testing/Application.java // public class Application extends android.app.Application { // private RuntimeApplicationComponent applicationComponent; // @Inject DependenciesInjector injector; // // @Override // public void onCreate() { // super.onCreate(); // initializeInjection(); // } // // private void initializeInjection() { // applicationComponent = DaggerRuntimeApplicationComponent.builder() // .runtimeApplicationModule(new RuntimeApplicationModule(this)) // .build(); // applicationComponent.inject(this); // } // // public ApplicationComponent getApplicationComponent() { // return applicationComponent; // } // // public DependenciesInjector getDependenciesInjector() { // return injector; // } // } // // Path: app/src/main/java/com/txusballesteros/testing/domain/repository/DashboardRepository.java // public interface DashboardRepository { // void getDashboard(final Callback callback); // // interface Callback { // void onSuccess(final List<Image> images); // void onError(); // } // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/PostExecutionThread.java // public interface PostExecutionThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/com/txusballesteros/testing/threading/ThreadExecutor.java // public interface ThreadExecutor extends Executor { } // // Path: app/src/main/java/com/txusballesteros/testing/view/instrumentation/ImageLoader.java // public interface ImageLoader { // void loadImageAsGif(Uri imageUrl, ImageView imageView); // } // Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java import javax.inject.Singleton; import dagger.Component; import com.txusballesteros.testing.Application; import com.txusballesteros.testing.domain.repository.DashboardRepository; import com.txusballesteros.testing.threading.PostExecutionThread; import com.txusballesteros.testing.threading.ThreadExecutor; import com.txusballesteros.testing.view.instrumentation.ImageLoader; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.internal.di; public interface ApplicationComponent { Application getApplication(); ThreadExecutor getThreadExecutor(); PostExecutionThread getPostExecutionThread(); ImageLoader getImageLoader();
DashboardRepository getDashboardRepository();
txusballesteros/Android-Clean-Testing
app/src/androidTest/java/com/txusballesteros/testing/instrumentation/view/internal/di/TestingActivityComponent.java
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/view/internal/di/ActivityComponent.java // public interface ActivityComponent { // void inject(MainActivity activity); // // Activity getActivity(); // }
import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.scopes.PerTest; import com.txusballesteros.testing.view.internal.di.ActivityComponent; import dagger.Component;
/* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.instrumentation.view.internal.di; @PerTest @Component(dependencies = ApplicationComponent.class, modules = TestingActivityModule.class)
// Path: app/src/main/java/com/txusballesteros/testing/internal/di/ApplicationComponent.java // public interface ApplicationComponent { // Application getApplication(); // ThreadExecutor getThreadExecutor(); // PostExecutionThread getPostExecutionThread(); // ImageLoader getImageLoader(); // DashboardRepository getDashboardRepository(); // } // // Path: app/src/main/java/com/txusballesteros/testing/view/internal/di/ActivityComponent.java // public interface ActivityComponent { // void inject(MainActivity activity); // // Activity getActivity(); // } // Path: app/src/androidTest/java/com/txusballesteros/testing/instrumentation/view/internal/di/TestingActivityComponent.java import com.txusballesteros.testing.internal.di.ApplicationComponent; import com.txusballesteros.testing.internal.di.scopes.PerTest; import com.txusballesteros.testing.view.internal.di.ActivityComponent; import dagger.Component; /* * Copyright Txus Ballesteros 2016 (@txusballesteros) * * This file is part of some open source application. * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Contact: Txus Ballesteros <[email protected]> */ package com.txusballesteros.testing.instrumentation.view.internal.di; @PerTest @Component(dependencies = ApplicationComponent.class, modules = TestingActivityModule.class)
public interface TestingActivityComponent extends ActivityComponent { }
afpdev/alpheusafpparser
src/main/java/com/mgz/afp/enums/AFPColorValue.java
// Path: src/main/java/com/mgz/util/UtilBinaryDecoding.java // public class UtilBinaryDecoding { // // // /** // * Converts the given short value to an array of byte of given length. In Java a short value has // * the size of 2 bytes. // */ // public static final byte[] shortToByteArray(short value, int nrOfBytes) { // byte[] result = new byte[nrOfBytes]; // for (int i = 0; i < nrOfBytes && i < 2; i++) { // result[nrOfBytes - 1 - i] = (byte) (value >>> (i * 8)); // } // return result; // } // // public static final short parseShort(InputStream is, int length) throws AFPParserException, IOException { // if (length > 2) { // throw new AFPParserException("Short has max length of two bytes."); // } // int result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += is.read(); // } // return (short) result; // } // // public static short parseShort(byte[] sfData, int offset, int length) throws AFPParserException { // if (length > 2) { // throw new AFPParserException("Short has max length of two bytes."); // } // short result = 0; // for (int i = 0; i < length; i++) { // result = (short) (result << 8); // result += (sfData[offset + i] & 0xFF); // } // return result; // } // // public static final int parseInt(InputStream is, int length) throws IOException { // if (length > 4) { // throw new IOException("Integer has max length of four bytes."); // } // int result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += is.read(); // } // return result; // } // // public static int parseInt(byte[] sfData, int offset, int length) throws AFPParserException { // if (length > 4) { // throw new AFPParserException("Integer has max length of four bytes."); // } // int result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += (sfData[offset + i] & 0xFF); // } // return result; // } // // /** // * Converts the given int value to an array of byte of given length. In Java an int value has the // * size of 4 bytes. // */ // public static final byte[] intToByteArray(int value, int nrOfBytes) { // byte[] result = new byte[nrOfBytes]; // for (int i = 0; i < nrOfBytes && i < 4; i++) { // result[nrOfBytes - 1 - i] = (byte) (value >>> (i * 8)); // } // return result; // } // // public static final long parseLong(InputStream is, int length) throws IOException { // if (length > 8) { // throw new IOException("Long integer has max length of eight bytes."); // } // long result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += is.read(); // } // return result; // } // // public static long parseLong(byte[] sfData, int offset, int length) throws AFPParserException { // if (length > 8) { // throw new AFPParserException("Long integer has max length of eight bytes."); // } // long result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += (sfData[offset + i] << 0) & 0xFF; // } // return result; // } // // /** // * Converts the given int value to an array of byte of given length. In Java an int value has the // * size of 4 bytes. // */ // public static final byte[] longToByteArray(long value, int nrOfBytes) { // byte[] result = new byte[nrOfBytes]; // for (int i = 0; i < nrOfBytes && i < 8; i++) { // result[nrOfBytes - 1 - i] = (byte) (value >>> (i * 8)); // } // return result; // } // // public static BitSet parseBitSet(byte[] sfData, int offset, int length) { // BitSet bitSet = new BitSet(length * 8); // // int pos = 0; // for (int i = 0; i < length; i++) { // byte b = sfData[offset + i]; // for (int j = 0; j < 8; j++) { // boolean val = (b & (0x01 << 7 - j)) != 0; // bitSet.set(pos, val); // pos++; // } // } // // return bitSet; // } // // public static byte[] bitSetToByteArray(BitSet bitSet, int byteLen) { // byte[] result = new byte[byteLen]; // // for (int i = 0; i < byteLen; i++) { // for (int j = 7; j >= 0; j--) { // if (bitSet.length() < (i * 8 + (7 - j))) { // return result; // } // // if (bitSet.get(i * 8 + (7 - j))) { // result[i] |= (0x01 << j); // } // } // } // // return result; // } // }
import com.mgz.afp.exceptions.AFPParserException; import com.mgz.util.UtilBinaryDecoding;
Default_0xFFFF(0xFFFF, 0, 0, 0); int code; int red, green, blue; AFPColorValue(int code, int red, int green, int blue) { this.code = code; this.red = red; this.green = green; this.blue = blue; } public static AFPColorValue valueOf(int code) throws AFPParserException { for (AFPColorValue cv : values()) { if (cv.code == code) { return cv; } } throw new AFPParserException(AFPColorValue.class.getSimpleName() + ": color code 0x" + Integer.toHexString(code) + " is undefined."); } public int toByte() { return code & 0xFF; } public int[] toRgb() { return new int[] {red, green, blue}; } public byte[] toByte2() {
// Path: src/main/java/com/mgz/util/UtilBinaryDecoding.java // public class UtilBinaryDecoding { // // // /** // * Converts the given short value to an array of byte of given length. In Java a short value has // * the size of 2 bytes. // */ // public static final byte[] shortToByteArray(short value, int nrOfBytes) { // byte[] result = new byte[nrOfBytes]; // for (int i = 0; i < nrOfBytes && i < 2; i++) { // result[nrOfBytes - 1 - i] = (byte) (value >>> (i * 8)); // } // return result; // } // // public static final short parseShort(InputStream is, int length) throws AFPParserException, IOException { // if (length > 2) { // throw new AFPParserException("Short has max length of two bytes."); // } // int result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += is.read(); // } // return (short) result; // } // // public static short parseShort(byte[] sfData, int offset, int length) throws AFPParserException { // if (length > 2) { // throw new AFPParserException("Short has max length of two bytes."); // } // short result = 0; // for (int i = 0; i < length; i++) { // result = (short) (result << 8); // result += (sfData[offset + i] & 0xFF); // } // return result; // } // // public static final int parseInt(InputStream is, int length) throws IOException { // if (length > 4) { // throw new IOException("Integer has max length of four bytes."); // } // int result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += is.read(); // } // return result; // } // // public static int parseInt(byte[] sfData, int offset, int length) throws AFPParserException { // if (length > 4) { // throw new AFPParserException("Integer has max length of four bytes."); // } // int result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += (sfData[offset + i] & 0xFF); // } // return result; // } // // /** // * Converts the given int value to an array of byte of given length. In Java an int value has the // * size of 4 bytes. // */ // public static final byte[] intToByteArray(int value, int nrOfBytes) { // byte[] result = new byte[nrOfBytes]; // for (int i = 0; i < nrOfBytes && i < 4; i++) { // result[nrOfBytes - 1 - i] = (byte) (value >>> (i * 8)); // } // return result; // } // // public static final long parseLong(InputStream is, int length) throws IOException { // if (length > 8) { // throw new IOException("Long integer has max length of eight bytes."); // } // long result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += is.read(); // } // return result; // } // // public static long parseLong(byte[] sfData, int offset, int length) throws AFPParserException { // if (length > 8) { // throw new AFPParserException("Long integer has max length of eight bytes."); // } // long result = 0; // for (int i = 0; i < length; i++) { // result = (result << 8); // result += (sfData[offset + i] << 0) & 0xFF; // } // return result; // } // // /** // * Converts the given int value to an array of byte of given length. In Java an int value has the // * size of 4 bytes. // */ // public static final byte[] longToByteArray(long value, int nrOfBytes) { // byte[] result = new byte[nrOfBytes]; // for (int i = 0; i < nrOfBytes && i < 8; i++) { // result[nrOfBytes - 1 - i] = (byte) (value >>> (i * 8)); // } // return result; // } // // public static BitSet parseBitSet(byte[] sfData, int offset, int length) { // BitSet bitSet = new BitSet(length * 8); // // int pos = 0; // for (int i = 0; i < length; i++) { // byte b = sfData[offset + i]; // for (int j = 0; j < 8; j++) { // boolean val = (b & (0x01 << 7 - j)) != 0; // bitSet.set(pos, val); // pos++; // } // } // // return bitSet; // } // // public static byte[] bitSetToByteArray(BitSet bitSet, int byteLen) { // byte[] result = new byte[byteLen]; // // for (int i = 0; i < byteLen; i++) { // for (int j = 7; j >= 0; j--) { // if (bitSet.length() < (i * 8 + (7 - j))) { // return result; // } // // if (bitSet.get(i * 8 + (7 - j))) { // result[i] |= (0x01 << j); // } // } // } // // return result; // } // } // Path: src/main/java/com/mgz/afp/enums/AFPColorValue.java import com.mgz.afp.exceptions.AFPParserException; import com.mgz.util.UtilBinaryDecoding; Default_0xFFFF(0xFFFF, 0, 0, 0); int code; int red, green, blue; AFPColorValue(int code, int red, int green, int blue) { this.code = code; this.red = red; this.green = green; this.blue = blue; } public static AFPColorValue valueOf(int code) throws AFPParserException { for (AFPColorValue cv : values()) { if (cv.code == code) { return cv; } } throw new AFPParserException(AFPColorValue.class.getSimpleName() + ": color code 0x" + Integer.toHexString(code) + " is undefined."); } public int toByte() { return code & 0xFF; } public int[] toRgb() { return new int[] {red, green, blue}; } public byte[] toByte2() {
return UtilBinaryDecoding.intToByteArray(code, 2);