diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..7cbdb519 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,31 @@ +version: 2 +jobs: + build: + working_directory: ~/ProductCatalog + docker: + - image: circleci/android:api-28-alpha + environment: + JVM_OPTS: -Xmx3200m + steps: + - checkout + - restore_cache: + key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} + - run: + name: Chmod permissions + command: sudo chmod +x ./gradlew + - run: + name: Download Dependencies + command: ./gradlew androidDependencies + - save_cache: + paths: + - ~/.gradle + key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} + - run: + name: Run UnitTest + command: ./gradlew test + - store_artifacts: + path: app/build/outputs/apk/debug/ + destination: apks/ + - store_test_results: + path: app/build/test-results + \ No newline at end of file diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 00000000..eaff333c Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 00000000..30aa626c --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43ef..00000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf33..00000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 3d21ecd0..e0d5b93f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,43 +1,35 @@ - - - - - - - - - - - - - - + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..b121d570 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# ProductCatalog +Build Status +[![Build Status](https://circleci.com/gh/SEG2105F18/ProductCatalog.png?branch=master)](https://circleci.com/gh/SEG2105F18/ProductCatalog) + diff --git a/app/build.gradle b/app/build.gradle index d4a120ec..149a4c2f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' +apply plugin: 'com.google.gms.google-services' android { - compileSdkVersion 25 - buildToolsVersion "25.0.3" + compileSdkVersion 28 defaultConfig { applicationId "mgarzon.createbest.productcatalog" minSdkVersion 15 - targetSdkVersion 25 + targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -17,18 +17,18 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) - compile 'com.android.support:appcompat-v7:25.3.1' - compile 'com.android.support.constraint:constraint-layout:1.0.2' - compile 'com.google.firebase:firebase-database:10.0.1' - testCompile 'junit:junit:4.12' -} + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.google.firebase:firebase-database:16.0.1' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'com.android.support.test:rules:1.0.2' -apply plugin: 'com.google.gms.google-services' \ No newline at end of file +} diff --git a/app/google-services.json b/app/google-services.json index e17dbfe4..d46f9546 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -1,35 +1,35 @@ { "project_info": { - "project_number": "767509833961", - "firebase_url": "https://productcatalog-d825a.firebaseio.com", - "project_id": "productcatalog-d825a", - "storage_bucket": "productcatalog-d825a.appspot.com" + "project_number": "549167445435", + "firebase_url": "https://productcatalogf18.firebaseio.com", + "project_id": "productcatalogf18", + "storage_bucket": "productcatalogf18.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:767509833961:android:aadfeba8c26d67fc", + "mobilesdk_app_id": "1:549167445435:android:aadfeba8c26d67fc", "android_client_info": { "package_name": "mgarzon.createbest.productcatalog" } }, "oauth_client": [ { - "client_id": "767509833961-6i2um8le0ig0dghdds1msdf8j909i4ie.apps.googleusercontent.com", + "client_id": "549167445435-bqkrnvemam2vlsbvo12db9e8f7o4kt2o.apps.googleusercontent.com", "client_type": 1, "android_info": { "package_name": "mgarzon.createbest.productcatalog", - "certificate_hash": "40cba294ec4e6b892de0a41c358747aba3d4eb1f" + "certificate_hash": "94a15cb9b346e4f7005039f06009b38c5c518158" } }, { - "client_id": "767509833961-lq1hebfu8a8q54uprv1o6dm9og3bfp20.apps.googleusercontent.com", + "client_id": "549167445435-oa6l951d32j9h3vqpa3vk2vd757in4ui.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { - "current_key": "AIzaSyDQ7OQ0R8lF4OAZvczE7cjNOWrdq9XBuKM" + "current_key": "AIzaSyBdcbJw4tB9eb0o9w1IcuCP6Pap_nphWPc" } ], "services": { @@ -40,7 +40,7 @@ "status": 2, "other_platform_oauth_client": [ { - "client_id": "767509833961-lq1hebfu8a8q54uprv1o6dm9og3bfp20.apps.googleusercontent.com", + "client_id": "549167445435-oa6l951d32j9h3vqpa3vk2vd757in4ui.apps.googleusercontent.com", "client_type": 3 } ] diff --git a/app/src/androidTest/java/mgarzon/createbest/productcatalog/FirstTest.java b/app/src/androidTest/java/mgarzon/createbest/productcatalog/FirstTest.java new file mode 100644 index 00000000..01d0adf9 --- /dev/null +++ b/app/src/androidTest/java/mgarzon/createbest/productcatalog/FirstTest.java @@ -0,0 +1,56 @@ +package mgarzon.createbest.productcatalog; + + +import android.support.test.filters.LargeTest; +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static android.support.test.espresso.Espresso.onData; +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard; +import static android.support.test.espresso.action.ViewActions.typeText; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.CoreMatchers.anything; + + +@RunWith(AndroidJUnit4.class) + @LargeTest + public class FirstTest { + + private String mStringToBetyped; + private String mNumberToBetyped; + @Rule + public ActivityTestRule mActivityRule = new ActivityTestRule<>( + MainActivity.class); + + @Before + public void initValidString() { + // Specify a valid string. + mStringToBetyped = "Espresso"; + mNumberToBetyped = "1234"; + } + + @Test + public void changeText_sameActivity() { + // Type text and then press the button. + onView(withId(R.id.editTextName)) + .perform(typeText(mStringToBetyped), closeSoftKeyboard()); + onView(withId(R.id.editTextPrice)) + .perform(typeText(mNumberToBetyped), closeSoftKeyboard()); + + onView(withId(R.id.addButton)).perform(click()); + + // Check that the text was changed. + //onView(withId(R.id.listViewProducts)) + // .check(matches(withText(mStringToBetyped))); + onData(anything()).inAdapterView(withId(R.id.listViewProducts)).atPosition(0).onChildView(withId(R.id.textViewName)).check(matches(withText("Hello"))); + + } + } diff --git a/app/src/test/java/mgarzon/createbest/productcatalog/ExampleUnitTest.java b/app/src/test/java/mgarzon/createbest/productcatalog/ExampleUnitTest.java deleted file mode 100644 index 19e81350..00000000 --- a/app/src/test/java/mgarzon/createbest/productcatalog/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package mgarzon.createbest.productcatalog; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/app/src/test/java/mgarzon/createbest/productcatalog/ProductTest.java b/app/src/test/java/mgarzon/createbest/productcatalog/ProductTest.java new file mode 100644 index 00000000..156cb97c --- /dev/null +++ b/app/src/test/java/mgarzon/createbest/productcatalog/ProductTest.java @@ -0,0 +1,27 @@ +package mgarzon.createbest.productcatalog; +import static org.junit.Assert.*; +import org.junit.Test; + +public class ProductTest { + + @Test + public void checkProductName() { + Product aProduct = new Product("1", "DELL MONITOR", 180); + assertEquals("Check the name of the product", "DELL MONITOR", aProduct.getProductName()); + } + + @Test + public void checkProductId() { + Product aProduct = new Product("1", "DELL MONITOR", 180); + assertEquals("Check the id of the product", "1", aProduct.getId()); + } + + @Test + public void checkProductPrice() { + // I am making this test to fail + Product aProduct = new Product("1", "DELL MONITOR", 180); + assertEquals("Check the price of the product", "0", aProduct.getPrice()); + } + + +} diff --git a/build.gradle b/build.gradle index 975acce8..05cbf9b9 100644 --- a/build.gradle +++ b/build.gradle @@ -2,20 +2,24 @@ buildscript { repositories { + google() jcenter() + } dependencies { - classpath 'com.android.tools.build:gradle:2.3.2' + classpath 'com.android.tools.build:gradle:3.2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files - classpath 'com.google.gms:google-services:3.0.0' + classpath 'com.google.gms:google-services:4.0.1' } } allprojects { repositories { + google() jcenter() + } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3c9b508e..7a175ffc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun May 07 11:02:30 EDT 2017 +#Thu Oct 18 15:38:05 EDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip