Skip to content

Commit 691f26b

Browse files
LajeshLajesh
authored andcommitted
Initial commit.
1 parent 58e5e1a commit 691f26b

File tree

95 files changed

+3078
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3078
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/libraries
5+
/.idea/modules.xml
6+
/.idea/workspace.xml
7+
.DS_Store
8+
/build
9+
/captures
10+
.externalNativeBuild

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: "org.sonarqube"
3+
apply plugin: 'jacoco'
4+
5+
jacoco {
6+
toolVersion = "0.8.1"
7+
}
8+
9+
tasks.withType(Test) {
10+
jacoco.includeNoLocationClasses = true
11+
}
12+
13+
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
14+
15+
reports {
16+
xml.enabled = true
17+
html.enabled = true
18+
}
19+
20+
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
21+
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
22+
def mainSrc = "$project.projectDir/src/main/java"
23+
24+
sourceDirectories = files([mainSrc])
25+
classDirectories = files([debugTree])
26+
executionData = fileTree(dir: project.buildDir, includes: [
27+
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
28+
])
29+
}
30+
31+
32+
33+
android {
34+
compileSdkVersion 28
35+
defaultConfig {
36+
applicationId "com.nytimes.articles"
37+
minSdkVersion 21
38+
targetSdkVersion 28
39+
versionCode 1
40+
versionName "1.0"
41+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
42+
}
43+
buildTypes {
44+
debug {
45+
testCoverageEnabled true
46+
}
47+
release {
48+
minifyEnabled false
49+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
50+
}
51+
}
52+
compileOptions {
53+
sourceCompatibility JavaVersion.VERSION_1_8
54+
targetCompatibility JavaVersion.VERSION_1_8
55+
}
56+
dataBinding {
57+
enabled = true
58+
}
59+
60+
testOptions {
61+
unitTests.all {
62+
jacoco {
63+
includeNoLocationClasses = true
64+
}
65+
}
66+
}
67+
68+
sonarqube {
69+
properties {
70+
property "sonar.sources", "src/main"
71+
property "sonar.projectName", "NYTimesApp" // Name of your project
72+
property "sonar.projectVersion", "1.0.2" // Version of your project
73+
property "sonar.projectDescription", "NYTimes Application to list popular Articles"
74+
}
75+
}
76+
}
77+
78+
dependencies {
79+
final SUPPORT_LIBRARY_VERSION = '28.0.0-alpha3'
80+
final ARCHITECTURE_COMPONENT_VERSION = '1.1.1'
81+
final RETROFIT_VERSION = '2.3.0'
82+
final DAGGER_VERSION = '2.15'
83+
final LOTTIE_ANDROID_VERSION = '2.5.4'
84+
final ROOM_VERSION = '1.1.1'
85+
86+
implementation fileTree(dir: 'libs', include: ['*.jar'])
87+
88+
// Android Support Library dependecies
89+
implementation "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
90+
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
91+
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
92+
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
93+
94+
// Unit test dependencies
95+
testImplementation 'junit:junit:4.12'
96+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
97+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
98+
99+
// Retrofit
100+
implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
101+
implementation "com.squareup.retrofit2:adapter-rxjava2:$RETROFIT_VERSION"
102+
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
103+
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
104+
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.6.0'
105+
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
106+
107+
108+
// RxJava / RxAndroid
109+
implementation 'io.reactivex.rxjava2:rxjava:2.1.10'
110+
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
111+
112+
// Dagger 2
113+
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
114+
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
115+
annotationProcessor "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
116+
annotationProcessor "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
117+
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
118+
119+
// Android Architecture Components
120+
implementation "android.arch.lifecycle:extensions:$ARCHITECTURE_COMPONENT_VERSION"
121+
implementation "android.arch.lifecycle:common-java8:$ARCHITECTURE_COMPONENT_VERSION"
122+
implementation "android.arch.lifecycle:reactivestreams:$ARCHITECTURE_COMPONENT_VERSION"
123+
124+
//Lottie Animation view
125+
implementation "com.airbnb.android:lottie:$LOTTIE_ANDROID_VERSION"
126+
127+
//Calligraphy for custom fonts
128+
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
129+
130+
131+
// Room SQLite for data persistence
132+
implementation "android.arch.persistence.room:runtime:$ROOM_VERSION"
133+
annotationProcessor "android.arch.persistence.room:compiler:$ROOM_VERSION"
134+
135+
// Chrome custom tab
136+
implementation 'com.android.support:customtabs:28.0.0-alpha3'
137+
138+
// optional - RxJava support for Room
139+
implementation "android.arch.persistence.room:rxjava2:$ROOM_VERSION"
140+
141+
implementation "com.squareup.okhttp3:mockwebserver:3.8.1"
142+
143+
androidTestImplementation 'com.android.support:support-annotations:27.1.1'
144+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
145+
androidTestImplementation 'com.android.support.test:rules:1.0.2'
146+
testImplementation 'org.mockito:mockito-core:2.7.6'
147+
148+
implementation 'org.jsoup:jsoup:1.10.2'
149+
150+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.nytimes.articles.dao;
2+
3+
import android.arch.lifecycle.LiveData;
4+
import android.arch.persistence.room.Room;
5+
import android.support.test.InstrumentationRegistry;
6+
import android.support.test.runner.AndroidJUnit4;
7+
8+
import com.nytimes.articles.data.local.ArticleDatabase;
9+
import com.nytimes.articles.data.local.entity.ArticleEntity;
10+
11+
import org.junit.After;
12+
import org.junit.Before;
13+
import org.junit.Test;
14+
import org.junit.runner.RunWith;
15+
16+
import java.util.ArrayList;
17+
import java.util.List;
18+
19+
import static org.junit.Assert.assertNotNull;
20+
21+
22+
@RunWith(AndroidJUnit4.class)
23+
public class ArticleDaosTest {
24+
25+
private ArticleDatabase articleDatabase;
26+
27+
@Before
28+
public void init(){
29+
articleDatabase = Room.inMemoryDatabaseBuilder(InstrumentationRegistry.getContext(), ArticleDatabase.class).build();
30+
}
31+
32+
@After
33+
public void uninit(){
34+
articleDatabase.close();
35+
}
36+
@Test
37+
public void testLoadPopularArticles(){
38+
List<ArticleEntity> articleEntities = new ArrayList<>();
39+
ArticleEntity entity = new ArticleEntity();
40+
entity.setId(1000);
41+
entity.setTitle("test");
42+
entity.setAuthors("test");
43+
entity.setPublishedDate("test");
44+
entity.setUrl("test");
45+
articleEntities.add(entity);
46+
articleDatabase.articleDao().saveArticles(articleEntities);
47+
LiveData<List<ArticleEntity>> articlesList = articleDatabase.articleDao().loadPopularArticles();
48+
assertNotNull(articlesList);
49+
}
50+
51+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.nytimes.articles.dao;
2+
3+
import android.support.test.espresso.Espresso;
4+
import android.support.test.rule.ActivityTestRule;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import com.nytimes.articles.R;
8+
import com.nytimes.articles.view.activity.MainActivity;
9+
import com.nytimes.articles.view.fragment.ArticleListFragment;
10+
11+
import org.junit.Before;
12+
import org.junit.Rule;
13+
import org.junit.Test;
14+
import org.junit.runner.RunWith;
15+
16+
import static android.support.test.espresso.action.ViewActions.click;
17+
import static android.support.test.espresso.matcher.ViewMatchers.withId;
18+
19+
20+
@RunWith(AndroidJUnit4.class)
21+
public class ArticleListTest {
22+
23+
@Rule
24+
//Activity Test Rule for the activity which contains my login fragment
25+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class);
26+
27+
@Before
28+
public void init() {
29+
//Initail setup method to load my fragment in the activity before beginning to test
30+
mActivityRule.getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragContainer, new ArticleListFragment()).commit();
31+
}
32+
33+
@Test
34+
public void OnRecyclerViewClick() throws InterruptedException {
35+
//Perform type action on the view with id as email
36+
Espresso.onView(withId(R.id.recyclerView)).perform(click());
37+
38+
}
39+
40+
@Test
41+
public void onSearchClick(){
42+
Espresso.onView(withId(R.id.action_search)).perform(click());
43+
44+
}
45+
}

app/src/main/AndroidManifest.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.nytimes.articles">
4+
5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
7+
<application
8+
android:name=".NYTimesApp"
9+
android:allowBackup="false"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true"
14+
android:theme="@style/AppTheme">
15+
<activity android:name=".view.activity.MainActivity">
16+
<meta-data
17+
android:name="android.app.searchable"
18+
android:resource="@xml/searchable" />
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
27+
</manifest>
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)