package de.philipphager.disclosure.database.app.model;

import de.philipphager.disclosure.database.mocks.MockApp;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static org.assertj.core.api.Assertions.assertThat;

@RunWith(MockitoJUnitRunner.class) public class AppShould {
  @Test public void useBuilderToSetAllFields() {
    App app = App.builder()
        .id(MockApp.TEST.id())
        .label(MockApp.TEST.label())
        .packageName(MockApp.TEST.packageName())
        .flags(MockApp.TEST.flags())
        .process(MockApp.TEST.process())
        .sourceDir(MockApp.TEST.sourceDir())
        .build();

    assertThat(app).isEqualTo(MockApp.TEST);
  }

  @Test public void allowIdToBeNull() {
    App app = App.builder()
        .label(MockApp.TEST.label())
        .packageName(MockApp.TEST.packageName())
        .flags(MockApp.TEST.flags())
        .process(MockApp.TEST.process())
        .sourceDir(MockApp.TEST.sourceDir())
        .build();

    assertThat(app.id()).isNull();
  }

  @Test(expected = IllegalStateException.class) public void throwErrorIfLabelIsNull() {
    App.builder()
        .packageName(MockApp.TEST.packageName())
        .flags(MockApp.TEST.flags())
        .process(MockApp.TEST.process())
        .sourceDir(MockApp.TEST.sourceDir())
        .build();
  }

  @Test(expected = IllegalStateException.class) public void throwErrorIfPackageNameIsNull() {
    App.builder()
        .label(MockApp.TEST.label())
        .flags(MockApp.TEST.flags())
        .process(MockApp.TEST.process())
        .sourceDir(MockApp.TEST.sourceDir())
        .build();
  }
}

@@ -516,32 +516,77 @@
 .packageName())%0A
+        .targetSdk(MockApp.TEST.targetSdk())%0A
         .flags(M
@@ -598,32 +598,32 @@
 p.TEST.flags())%0A
-
         .process
@@ -907,32 +907,77 @@
 .packageName())%0A
+        .targetSdk(MockApp.TEST.targetSdk())%0A
         .flags(M
@@ -1326,32 +1326,77 @@
 p.TEST.flags())%0A
+        .targetSdk(MockApp.TEST.targetSdk())%0A
         .process
@@ -1592,32 +1592,32 @@
   App.builder()%0A
-
         .label(M
@@ -1629,32 +1629,77 @@
 p.TEST.label())%0A
+        .targetSdk(MockApp.TEST.targetSdk())%0A
         .flags(M

Update app tests