## java – Multiple services with common code that gets a map and sets objects’ prop using the map data

I have the following service class:

``````@Service
@RequiredArgsConstructor
public class AutoVendorNameService  {

// client of a 3rd party web service
private final AutoClient autoClient;

public void setAutoVendorName(ReportCars cars) {

// autoVendorNamesById: car id is key and vendor name is value
Map<String, String> autoVendorNamesById =
autoClient.getAutoVendorName(cars.getIds()); //cars.getIds() returns Set<String>

for (ReportCar car : cars.getReportCars()) {
String autoVendorName= autoVendorNamesById.get(car.getId());
car.setAutoVendorName(autoVendorName);
}
}

}
``````

Then, I have other services that have similar functionality. For example,

``````@Service
@RequiredArgsConstructor
public class AutoDealerNameService  {

// client of a 3rd party web service interface
private final AutoClient autoClient;

public void setAutoDealerName(ReportCars cars) {

// autoDealerNamesById: car id is key and dealer name is value
Map<String, String> autoDealerNamesById =
autoClient.getAutoDealerName(cars.getIds()); //cars.getIds() returns Set<String>

for (ReportCar car : cars.getReportCars()) {
String autoDealerName= autoDealerNamesById.get(car.getId());
car.setAutoDealerName(autoDealerName);
}
}

}
``````

There are few services that have a different value type in the map but follow the same boilerplate. For example, I have a `AutoPriceService` that `Map<String, BigDecimal> autoPriceById`.

Is there a way to write a generic method to help reduce this boilerplate duplicative code? I’m using Java 8.

## javascript – Testing a React component which receives a function as a prop

Suppose there’s a root `<App />` which houses multiple components, one of them being, say `<SearchBox />`.

App component houses the app state (such as `searchResults` array) and iterates the results underneath the `<SearchBox onResults={this.onResults}/>` as `<SearchResult url={url} title={title}/>`

Inside the SearchBox component, a call to a library is made which in turn calls a remote API, which then returns results back to `onResults` that is passed to the child SearchBox.

In other words, we have:

App (has state which is modified w/ `onResult`) -> `SearchBox` (receives `onResult`) -> API Call

and then:

API Call -> `SearchBox` -> `<App />` (via `onResult` callback) -> Update state -> Render results in `<App />`

What is the appropriate way of testing the functionality of `<SearchBox />` component given that it relies on being passed a function from the parent?

I’m thinking:

• Mock the prop
• Mock the search library (return some fixture)
• Test the component “in a vacuum” and see if the mocked function runs?

Or should this be tested by instead testing the parent component and supplying an unadulterated `onResults` from the parent and somehow watching that it was in fact called?

What is the appropriate way to test this component setup? Is this spilling over into integration testing territory vs unit testing? (on that point, how would an integration test be setup if it relies on a call to an API which may or may not be successful?)

## propositional calculus – Understanding \$PROP\$ set in the book Logic and Structure (Van Dalen).

Working on the book: Dirk van Dalen. “Logic and Structure (Universitext)” (p. 18)

Definition 1.1.2 The set PROP of propositions is the smallest set X with the properties

$$begin{array}{rl} rm(i)&p_iin X(iin N),botin X,\ rm(ii)&varphi,psiin XRightarrow(varphiwedgepsi),(varphiveepsi),(varphitopsi),(varphileftrightarrowpsi)in X,\ rm(iii)&varphiin XRightarrow(negvarphi)in X.\ end{array}$$

I would like to know:

$$p_iin X(iin N),botin X$$

• How can I instantiate this statement when verifiyng a string of symbols belongs to PROP ?
• Is the comma an and connective ?
• What is $$N$$?
• Why is bottom symbol there ?

$$((p land q) to p)$$

• How can I show this statement belongs to PROP ?

P.S.: I am already aware of similar questions but they do not address my questions, I think.

## gr.group theory – Infinite pro-\$p\$ group of finite solvable length and finite coclass

I was reading about infinite pro-$$p$$ groups of finite coclass from the book “The Structure of Groups of Prime Power Order” by Leedham-Green and McKay. I asked this question in math.stackExchange before posting it here; there were no answers there, I thought I might share it in mathoverflow. My advance apologies if anything is inappropriate.

I was thinking about solvability and I think it can be shown that if $$G$$ is a solvable group of solvable length $$l$$ then every subgroup and quotient of $$G$$ has solvable length at most $$l$$ (please correct me if I am wrong). My question is related to the “opposite” of this property.

My question is

Let $$S$$ be an infinite pro-$$p$$ group of finite coclass. Suppose there exists a non-negative integer $$t$$ such that the solvable length of each lower central series quotient $$S/gamma_i(S)$$ is less than or equal to $$l$$ for all $$ige t$$. Then is it true that the $$S$$ is solvable with solvable length less than or equal to $$l$$?

To recall, the coclass of a finite $$p$$-group $$G$$ of order $$p^n$$ is defined as $$n-c$$ where $$c$$ is the nilpotency class of $$G$$. In case of infinite pro-$$p$$ groups, an infinite pro-$$p$$ group $$S$$ is said to be of finite coclass $$r$$ if its lower central series quotients $$S/gamma_i(S)$$ are finite $$p$$-groups and $$S/gamma_i(S)$$ has coclass $$r$$ for all $$ige t$$ for some $$tge 0$$.

## reactjs – How to ensure parent component passes the same prop function to child to avoid rerender

Currently I have a two component set up, where the parent renders some data and handles retrieval and the child is a filter. This filter allows the user to filter by status or keyword. Nothing fancy.

Now this is a paginated system. After the parent makes an initial request for data, they’re given the next page ID to request if they want more. But if the filter is updated, this next page ID needs to be wiped out, as it’s no good.

So what I do is pass a function from the parent to the child called `updateFilter()`. If the filter component has an update in state, it calls up to the parent and runs `updateFilter()`. One of the values updated is included in a `useEffect()` dependency array, so the parent then requests the new data with the new filters. Easy.

The problem is in setting up the child’s `useEffect()`. Eslint tells me I need to add `props.updateFilter` to the dependency array, and while I can just ignore this, I feel that it’s wrong. But the parent has a fair bit of state that will update, and when it does, it passes a new copy of `updateFilter()` down into the child which causes it to incorrectly trigger.

How do I go about fixing this? Can I tell the child to only use a static version of this function somehow? Or do I just exclude `props.updateFilter` from the dependency array? Below is a rough psuedo code of my components.

``````Parent {
const (stateVal, setStateVal) = useState(...);

function updateFilter(filterStatus) {
...
setStateVal(filterStatus);
}

useEffect(() => ..., (stateVal));

return <Child updateFilter={updateFilter} />
}

Child {
const (filterStatus, setStatus) = useState(...);

useEffect(() => {
props.updateFilter(filterStatus);
}, (filterStatus) // Adding `props` here is what I think I should do, but that causes the issue. Apparently the `props` val changes every time Parent's state changes

return ( ... );
}
``````

## javascript – React Prop has no value, can not connect to the console

I'm trying to transmit API data to App.js in the form of an accessory. I can log the API data through the console so that I know it is transmitted When I assign it to an accessory, I get ResultList.js: 28 Uncaught (in promised)
TypeError: this.props.openState is not a function. Is this the correct syntax? Sorry if it's a naive question I'm very new to all of this.

I've tried to assign it in different ways, but my lack of familiarity with the accessories bothers me. I know the API is returning data because I can log it through the console.

``````                `` `` state = {
`` `` openState: [],
`` `` proPublica: []
`` ``}

`` `` onSearchSubmit = zip code => {
`` `` const data = zipcodes.lookup (zipcode);
`` `` const state = data.state;
`` `` const lat = data.latitude.toFixed (2);
`` `` const lon = data.longitude.toFixed (2);

`` `` const openStateQuery = "lat =" + lat + "& long =" + lon;

`` `` API.getOpenStateData ("api / v1 / legislators / geo /?" + `` `` `OpenStateQuery) .then (OSresponse => {

=============================================== === ======================
`` `` this.props.openState (OSresponse.data) // convert data to prop `so that we can pass them to app.js
`` `` console.log ("OSresponse:", OSresponse.data);
`` `` console.log (this.props.openState)
=============================================== === =======================

I would expect the same answer as
console.log ("OSresponse:", OSresponse.data);
``````

## For a pro-p group, profinite, the finite generated abelianization is identical to that generated topologically.

I remember reading (without proof) that for $$Gamma$$ a profinite,$$p$$ group, the following items are equivalent:

1) Each open subgroup $$Gamma_0$$ is topologically generated finely.

2) The abelianization of each open subgroup $$Gamma_0$$ is generated (as $$mathbb Z_p$$ module.

3) Each open subgroup $$Gamma_0$$ admits only finely many cards $$Gamma_0 to mathbb F_p$$.

Clearly, $$1) implies 2) implies 3)$$ but how do you show equivalence?