Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Here is it I add value about user.
val user = hashMapOf(
USER_CONVERSATIONS to arrayListOf(""),
USER_EMAIL_COLUMN to personEmail,
USER_NAME_COLUMN to personName,
USER_PHOTO_URL_COLUMN to personPhoto.toString(),
USER_ID_COLUMN to personId
)
db.collection("users").add(user)
Which rule do I need to put inside Cloud Filestore or checking inside app?
Here is it my structure: https://imgur.com/a/w0AltSf
Thank you for extended answer!
I would like to do not register my account with new id, and check this in app, answer was given, thank you!
You can request to know if that document exists before inserting it. You can use something like this.
firestore.collection("users").whereEqualTo("id", YOUR_USER_ID)
.limit(1).get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
#Override
public void onComplete(#NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
// You can check here if document exist.
// It will be empty if it doesnt.
boolean isEmpty = task.getResult().isEmpty();
}
}
});
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 days ago.
Improve this question
I would like to ask you about JPA with projection.
Noted: I would like to update new value to getChild.
// From Folder Projection
public interface AuthMenu {
Long getMenuId();
String getMenuName();
String getMenuLink();
List<AuthSubMenu> getChild();
}
// From Folder Service implements
#Override
public List<AuthMenu> getListMenuByRoleUser(Long UserId) {
List<Integer> _actionIds = roleActionsRepository.getListActionIds(UserId);
List<AuthMenu> listMenu = menuRepository.getListMenuIds(1,_actionIds);
for (int i = 0; i < listMenu.size(); i++) {
// Want to update new value <-
}
return listMenu;
}
Could you help me please?
My expectation is want to update new value to getChild().
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a question about param, what param to present the class, such as if I findBuildingsType( buildingEntities, Village) it will return all village building as a result
Welcome.
You can deliver a Class via arguments like this:
private List<Building> findBuildingsType(List<Building> buildings, Class<? extends Building> typ) {
List<Building> re = new ArrayList<>();
for (Building building : buildings) {
if (typ.isInstance(building)) {
re.add(building);
}
}
return re;
}
Especially for your problem consider using streams:
List<Building> buildingsOfTypeMansion = buildings.stream().filter(building -> building instanceof Mansion).collect(Collectors.toList());
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
From immutability's point of view, is there any concerns for this code ?
public class mainPkg {
private boolean MyFunc1(MyInfo info) {
List<MyObj> myList = new ArrayList<MyObj>();
anotherPkg.MyFunc2(info, myList);
anotherPkg.MyFunc3(info, myList);
return CollectionUtils.isEmpty(myList);
}
}
public class anotherPkg {
public static boolean MyFunc2(MyInfo info, List<MyObj> myList) {
if(info.version < 2) {
myList.add(new MyObj('wrong version'));
return false;
}
return true;
}
}
MyFunc1(), MyFunc2() are used only in 1 place, and will only be used in this place. When i pass list as argument into myFunc2, it's like the classic call by reference. Not using global variable for myFunc1().
From immutability's point of view, what're are the concerns for this code ?
You are mutating the list referenced by myList in MyFunc2, therefore, your code is not immutable, therefore, it doesn't make sense to look at concerns "from immutability's point of view".
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I want to write a test case for the given method
private String productCode;
public PaymentManager() {
this.productCode = "SMART-TV;
}
#Override
public boolean isResponsibleFor(TransactionDetailResource resource) {
return productCode.equals(resource.getProductCode());
}
How to write test case for this method
First, create a test class and a test function
#Test
public void testIsResponsibleFor() {
...
}
(If you are using Eclipse, you can press Ctrl+J, It will automatically create the test class for you)
Then in your test function you must create your two objects, one PaymentManager and one TransactionDetailResource.
PaymentManager p = PaymentManager();
TransactionDetailResource t = TransactionDetailResource();
t.setProductCode("SMART-TV")
I have assumed you got a Setter in your TransactionDetailResource class.
AssertThat(p.isResponsibleFor(t),is(Boolean.True))
This is a partial answer but It can gives you a starting point
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
public void printSummaryForPatient(String name){
Patient p = findPatient(name);
p.printPatientSummary();
p.computeBMI();
}
My method to test:
#Test
public void testPrintSummaryForPatient() {
Patient patient_adult=new Patient("Ted",24,1.90,70.0,"Leicester");
//Patient Patient_child=new Patient("Kate",4,1.90,70.0,"Leicester");
// Patient Patient_elderly=new Patient("Bill",124,1.90,70.0,"Leicester");
surgery_N.findPatient("Ted");
patient_adult.printPatientSummary();
assertEquals("Ted", patient_adult.getName());
assertEquals("-----------PATIENT SUMMARY: ---------"+"\n"+"NAME: "+patient_adult.name+"\n"+"Age: "+patient_adult.getAge()+"\n"+"Address: "+patient_adult.getAddress()+"\n"+"Height: "+patient_adult.getHeight()+"\n"+"Weight: "+patient_adult.getWeight()+"\n"+"------------------------------"+separator,ans.toString());
patient_adult.computeBMI();
assertEquals(19.390581717451525, patient_adult.computeBMI(), 0.0);
}`
The problem is that the way I use to test doesn't cover the original file at all. Hope I can get some help from you guys.
You could assign a different writer to System.out (assuming that's where your output goes) and inspect what gets written there. In general, you probably want to make the writer a parameter of printSummary or inject it into the class somehow.
So basically you want to do this:
#Test
public void testPrintSummaryForPatient() {
Patient patient_adult=new Patient("Ted",24,1.90,70.0,"Leicester");
surgery_N.printSummaryForPatient("Ted");
}
But can't do any asserts, because the Patient is not returned.
Do you want to return the patient?:
public Patient printSummaryForPatient(String name){
Patient p = findPatient(name);
p.printPatientSummary();
p.computeBMI();
return p;
}
After that you could use your assertions. It seems more like a conceptual problem of how you organize your methods.
You have methods in printSummaryForPatient, that don't seem to do anything. Their return value is not returned or saved.