Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 380 notation primary key #490

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1896005
Add interface PrimariKey
diogosq Jan 6, 2016
0bed2a1
Add interface PrimariKey
diogosq Jan 6, 2016
3e3e3ea
ADD findById using primaryKey notation
diogosq Jan 6, 2016
b0ccc21
ADD findById using where and primaryKey notation
diogosq Jan 6, 2016
53729a8
ADD save using primaryKey notation
diogosq Jan 6, 2016
131b58f
ADD update using primaryKey notation
diogosq Jan 6, 2016
6a09b04
ADD inflate using primaryKey notation
diogosq Jan 6, 2016
3f695c4
PROBLEM DELETE METHOD WITHOUT OBJECT CAN BE USE PRIMARYKEY NOTATION
diogosq Jan 6, 2016
62537a7
ADD delete using object and primaryKey notation
diogosq Jan 6, 2016
24e769b
ADD last FIXME TO THIS
diogosq Jan 6, 2016
61d1561
ADD SchemaGenerator to use primaryKey notation
diogosq Jan 8, 2016
e0a468c
ADD Bugfix if condition to use primaryKey notation
diogosq Jan 8, 2016
92fc2ca
ADD JUnit BigDecimal using pk notation and table notation without id …
diogosq Jan 8, 2016
e3cb720
ADD JUnit BooleanField test using pk notation and table notation wit…
diogosq Jan 8, 2016
89c43b0
ADD JUnit BooleanField test using pk notation and table notation wit…
diogosq Jan 8, 2016
2403f09
BUGFIX Primary key find logic
diogosq Jan 8, 2016
39e4e60
ADD SimpleAnnotatedModelTest using pk notation
diogosq Jan 8, 2016
8a5a9b1
BUGFIX Detected by PrimaryKeyNotationSimpleAnnotatedModelTest
diogosq Jan 8, 2016
aea83ac
Detached pk notation tests of old tests
diogosq Jan 8, 2016
aebd1fe
ADD PrimaryKeyNotationRelationshipAnnotatedTests
diogosq Jan 8, 2016
fa319d7
ADD PrimaryKeyNotationRelationshipExtendedTests
diogosq Jan 8, 2016
0681b2b
ADD PrimaryKeyNotationRelationshipExtendedTests
diogosq Jan 8, 2016
0670f96
ADD PrimaryKeyNotationRelationshipExtendedTests
diogosq Jan 8, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.models;

import com.orm.dsl.PrimaryKey;
import com.orm.dsl.Table;

import java.math.BigDecimal;

@Table
public class PrimaryKeyNotationBigDecimalFieldAnnotatedModel{

@PrimaryKey
private Long myId;
private BigDecimal decimal;

public PrimaryKeyNotationBigDecimalFieldAnnotatedModel() {}

public PrimaryKeyNotationBigDecimalFieldAnnotatedModel(BigDecimal decimal) {
this.decimal = decimal;
}

public BigDecimal getBigDecimal() {
return decimal;
}

public Long getMyId() {
return myId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.models;

import com.orm.dsl.PrimaryKey;
import com.orm.dsl.Table;

@Table
public class PrimaryKeyNotationBooleanFieldAnnotatedModel{
private Boolean objectBoolean;
private boolean rawBoolean;
@PrimaryKey private Long myId;

public PrimaryKeyNotationBooleanFieldAnnotatedModel(){}

public PrimaryKeyNotationBooleanFieldAnnotatedModel(Boolean objectBoolean){
this.objectBoolean = objectBoolean;
}

public PrimaryKeyNotationBooleanFieldAnnotatedModel(boolean rawBoolean) {
this.rawBoolean = rawBoolean;
}

public Boolean getBoolean() {
return objectBoolean;
}

public boolean getRawBoolean() {
return rawBoolean;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.models;

import com.orm.dsl.PrimaryKey;
import com.orm.dsl.Table;

@Table
public class PrimaryKeyNotationRelationshipAnnotatedModel{
private SimpleAnnotatedModel simple;
@PrimaryKey private Long myId;

public PrimaryKeyNotationRelationshipAnnotatedModel(){}

public PrimaryKeyNotationRelationshipAnnotatedModel(SimpleAnnotatedModel simple){
this.simple = simple;
}

public SimpleAnnotatedModel getSimple(){
return simple;
}

public Long getMyId(){
return myId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.models;


import com.orm.SugarRecord;
import com.orm.dsl.PrimaryKey;

public class PrimaryKeyNotationRelationshipExtendedModel extends SugarRecord{

@PrimaryKey private Long myId;

private SimpleExtendedModel simple;

public PrimaryKeyNotationRelationshipExtendedModel(){}

public PrimaryKeyNotationRelationshipExtendedModel(SimpleExtendedModel simple){
this.simple = simple;
}

public SimpleExtendedModel getSimple(){
return simple;
}

public Long getMyId(){
return myId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.models;

import com.orm.dsl.PrimaryKey;
import com.orm.dsl.Table;

@Table
public class PrimaryKeyNotationSimpleAnnotatedModel{

@PrimaryKey private Long myId;

public PrimaryKeyNotationSimpleAnnotatedModel(){}

public Long getMyId(){
return myId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.example.models;

import com.orm.SugarRecord;
import com.orm.dsl.PrimaryKey;

public class PrimaryKeyNotationSimpleModel extends SugarRecord{
@PrimaryKey
private Long myId;
private String str;
private int integer;
private boolean bool;

public String getStr(){
return str;
}

public void setStr(String str){
this.str = str;
}

public int getInteger(){
return integer;
}

public void setInteger(int integer){
this.integer = integer;
}

public boolean isBool(){
return bool;
}

public void setBool(boolean bool){
this.bool = bool;
}

public Long getMyId(){ return myId; }

public void setMyId(Long myId){ this.myId = myId; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,42 @@

import java.math.BigDecimal;


import static com.orm.SugarRecord.save;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

@RunWith(RobolectricGradleTestRunner.class)
@Config(sdk=18)
public class BigDecimalFieldTests {
@RunWith (RobolectricGradleTestRunner.class)
@Config (sdk = 18)
public class BigDecimalFieldTests{
@Test
public void nullBigDecimalExtendedTest() {
public void nullBigDecimalExtendedTest(){
save(new BigDecimalFieldExtendedModel());
BigDecimalFieldExtendedModel model =
SugarRecord.findById(BigDecimalFieldExtendedModel.class, 1);
BigDecimalFieldExtendedModel model = SugarRecord.findById(BigDecimalFieldExtendedModel.class, 1);
assertNull(model.getBigDecimal());
}

@Test
public void nullBigDecimalAnnotatedTest() {
public void nullBigDecimalAnnotatedTest(){
save(new BigDecimalFieldAnnotatedModel());
BigDecimalFieldAnnotatedModel model =
SugarRecord.findById(BigDecimalFieldAnnotatedModel.class, 1);
BigDecimalFieldAnnotatedModel model = SugarRecord.findById(BigDecimalFieldAnnotatedModel.class, 1);
assertNull(model.getBigDecimal());
}

@Test
public void bigDecimalExtendedTest() {
public void bigDecimalExtendedTest(){
BigDecimal decimal = new BigDecimal(1234.5678901234567890123456789);
save(new BigDecimalFieldExtendedModel(decimal));
BigDecimalFieldExtendedModel model = SugarRecord.findById(BigDecimalFieldExtendedModel.class, 1);
assertEquals(decimal, model.getBigDecimal());
}

@Test
public void bigDecimalAnnotatedTest() {
public void bigDecimalAnnotatedTest(){
BigDecimal decimal = new BigDecimal(1234.5678901234567890123456789);
save(new BigDecimalFieldAnnotatedModel(decimal));
BigDecimalFieldAnnotatedModel model =
SugarRecord.findById(BigDecimalFieldAnnotatedModel.class, 1);
BigDecimalFieldAnnotatedModel model = SugarRecord.findById(BigDecimalFieldAnnotatedModel.class, 1);
assertEquals(decimal, model.getBigDecimal());
}

}
41 changes: 21 additions & 20 deletions example/src/test/java/com/example/sugartest/BooleanFieldTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,76 @@


import com.example.models.BooleanFieldAnnotatedModel;
import com.example.models.BooleanFieldExtendedModel;
import com.orm.SugarRecord;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;


import static com.orm.SugarRecord.save;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

@RunWith(RobolectricGradleTestRunner.class)
@Config(sdk=18)
public class BooleanFieldTests {
@RunWith (RobolectricGradleTestRunner.class)
@Config (sdk = 18)
public class BooleanFieldTests{
@Test
public void nullBooleanExtendedTest() {
save(new BooleanFieldExtendedModel());
BooleanFieldExtendedModel model = SugarRecord.findById(BooleanFieldExtendedModel.class, 1);
public void nullBooleanExtendedTest(){
save(new BooleanFieldAnnotatedModel());
BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
assertNull(model.getBoolean());
}

@Test
public void nullRawBooleanExtendedTest() {
save(new BooleanFieldExtendedModel());
BooleanFieldExtendedModel model = SugarRecord.findById(BooleanFieldExtendedModel.class, 1);
public void nullRawBooleanExtendedTest(){
save(new BooleanFieldAnnotatedModel());
BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
assertEquals(false, model.getRawBoolean());
}

@Test
public void nullBooleanAnnotatedTest() {
public void nullBooleanAnnotatedTest(){
save(new BooleanFieldAnnotatedModel());
BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
assertNull(model.getBoolean());
}

@Test
public void nullRawBooleanAnnotatedTest() {
public void nullRawBooleanAnnotatedTest(){
save(new BooleanFieldAnnotatedModel());
BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
assertEquals(false, model.getRawBoolean());
}

@Test
public void objectBooleanExtendedTest() {
public void objectBooleanExtendedTest(){
Boolean objectBoolean = new Boolean(true);
save(new BooleanFieldExtendedModel(objectBoolean));
BooleanFieldExtendedModel model = SugarRecord.findById(BooleanFieldExtendedModel.class, 1);
save(new BooleanFieldAnnotatedModel(objectBoolean));
BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
assertEquals(objectBoolean, model.getBoolean());
}

@Test
public void rawBooleanExtendedTest() {
save(new BooleanFieldExtendedModel(true));
BooleanFieldExtendedModel model = SugarRecord.findById(BooleanFieldExtendedModel.class, 1);
public void rawBooleanExtendedTest(){
save(new BooleanFieldAnnotatedModel(true));
BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
assertEquals(true, model.getRawBoolean());
}

@Test
public void objectBooleanAnnotatedTest() {
public void objectBooleanAnnotatedTest(){
Boolean objectBoolean = new Boolean(true);
save(new BooleanFieldAnnotatedModel(objectBoolean));
BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
assertEquals(objectBoolean, model.getBoolean());
}

@Test
public void rawBooleanAnnotatedTest() {
public void rawBooleanAnnotatedTest(){
save(new BooleanFieldAnnotatedModel(true));
BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
assertEquals(true, model.getRawBoolean());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.example.sugartest;


import com.example.models.PrimaryKeyNotationBigDecimalFieldAnnotatedModel;
import com.orm.SugarRecord;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;

import java.math.BigDecimal;


import static com.orm.SugarRecord.save;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

@RunWith (RobolectricGradleTestRunner.class)
@Config (sdk = 18)
public class PrimaryKeyNotationBigDecimalFieldTests{

@Test
public void primryKeyNotationNullBigDecimalExtendedTest(){
save(new PrimaryKeyNotationBigDecimalFieldAnnotatedModel());
PrimaryKeyNotationBigDecimalFieldAnnotatedModel model =
SugarRecord.findById(PrimaryKeyNotationBigDecimalFieldAnnotatedModel.class, 1);
assertNull(model.getBigDecimal());
}

@Test
public void primryKeyNotationBigDecimalExtendedTest(){
BigDecimal decimal = new BigDecimal(1234.5678901234567890123456789);
save(new PrimaryKeyNotationBigDecimalFieldAnnotatedModel(decimal));
PrimaryKeyNotationBigDecimalFieldAnnotatedModel model =
SugarRecord.findById(PrimaryKeyNotationBigDecimalFieldAnnotatedModel.class, 1);
assertEquals(decimal, model.getBigDecimal());
}

@Test
public void primryKeyNotationBigDecimalAnnotatedTest(){
BigDecimal decimal = new BigDecimal(1234.5678901234567890123456789);
save(new PrimaryKeyNotationBigDecimalFieldAnnotatedModel(decimal));
PrimaryKeyNotationBigDecimalFieldAnnotatedModel model =
SugarRecord.findById(PrimaryKeyNotationBigDecimalFieldAnnotatedModel.class, 1);
assertEquals(decimal, model.getBigDecimal());
}
}
Loading