dotansimha / dotansimha/graphql-code-generator-community
2 Java tests failing on master on Windows
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
**Describe the bug**
The "Should produce valid Java code" and "Should use the correct package name by default" tests are failing without any changes.
**To Reproduce**
Steps to reproduce the behavior:
yarn
yarn build
yarn test
**Expected behavior**
All tests passing.
**Environment:**
- OS: Windows 10
- `@graphql-codegen/...`: I checked out master
- NodeJS: 10.15.1
**Additional context**
Output of `yarn test`:
```
$ yarn test
yarn run v1.9.4
$ lerna run test --ignore @graphql-codegen/live-demo --ignore @graphql-codegen/website
lerna notice cli v3.18.3
lerna notice filter excluding ["@graphql-codegen/live-demo","@graphql-codegen/website"]
lerna info filter [ '!@graphql-codegen/live-demo', '!@graphql-codegen/website' ]
lerna info Executing command in 30 packages: "yarn run test"
lerna info run Ran npm script 'test' in '@graphql-codegen/plugin-helpers' in 1.9s:
$ jest --config ../../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/core' in 2.3s:
$ jest --config ../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/fragment-matcher' in 2.7s:
$ jest --config ../../../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/introspection' in 2.3s:
$ jest --config ../../../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/relay-operation-optimizer' in 2.7s:
$ jest --config ../../../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/schema-ast' in 2.8s:
$ jest --config ../../../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/visitor-plugin-common' in 2.9s:
$ jest --config ../../../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/typescript-graphql-files-modules' in 2.6s:
$ jest --config ../../../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/cli' in 6.1s:
$ jest --config ../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/flow' in 4.9s:
$ jest --config ../../../../jest.config.js
lerna info run Ran npm script 'test' in '@graphql-codegen/java-apollo-android' in 5.0s:
$ jest --config ../../../../jest.config.js
lerna ERR! yarn run test exited 1 in '@graphql-codegen/java'
lerna ERR! yarn run test stdout:
$ jest --config ../../../../jest.config.js
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run test stderr:
ts-jest[config] (WARN) TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
message TS151001: If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript confi
guration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecm
ascript-module-interoperability for more information.
FAIL tests/java.spec.ts
Java
× Should produce valid Java code (617ms)
Config
× Should use the correct package name by default (4ms)
√ Should use the package name provided from the config (2ms)
Enums
√ Should add imports that are relevant to enums (1ms)
√ Should generate basic enums correctly (2ms)
√ Should allow to override enum values with custom values (1ms)
Input Types / Arguments
√ Should generate arguments correctly when using Array (3ms)
√ Should generate input class per each type with field arguments (3ms)
√ Should generate input class per each query with arguments (3ms)
√ Should generate input class per each input, also with nested input types (2ms)
● Java › Should produce valid Java code
Invalid Java code:
line 1:11 token recognition error at: '\'
line 1:16 token recognition error at: '\'
line 1:12 mismatched input 'java' expecting ';'
line 3:0 extraneous input 'import' expecting {, 'abstract', 'class', 'enum', 'final', 'interface', 'private', 'protected', 'publ
ic', 'static', 'strictfp', ';', '@'}
line 4:0 extraneous input 'import' expecting {, 'abstract', 'class', 'enum', 'final', 'interface', 'private', 'protected', 'publ
ic', 'static', 'strictfp', ';', '@'}
line 5:0 extraneous input 'import' expecting {, 'abstract', 'class', 'enum', 'final', 'interface', 'private', 'protected', 'publ
ic', 'static', 'strictfp', ';', '@'}
line 6:0 extraneous input 'import' expecting {, 'abstract', 'class', 'enum', 'final', 'interface', 'private', 'protected', 'publ
ic', 'static', 'strictfp', ';', '@'}
13 | const mergedErrors = collectedErrors.join('\n');
14 |
> 15 | throw new Error(`Invalid Java code:\n${mergedErrors}`);
| ^
16 | }
17 | }
18 |
at Object.validateJava (../common/tests/validate-java.ts:15:11)
at Object.it (tests/java.spec.ts:68:5)
● Java › Config › Should use the correct package name by default
expect(received).toContain(expected) // indexOf
Expected substring: "package com.java.generated;"
Received string: "package com\\java\\generated;·
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.stream.Collectors;·
public class Types {···
public static class InputWithArrayInput {
private Iterable _f;
private Iterable _g;···
public InputWithArrayInput(Map args) {
if (args != null) {
this._f = (Iterable) args.get(\"f\");
this._g = ((List>) args.get(\"g\")).stream().map(SearchUserInput::new).collect(Collectors.toList());
}
}···
public Iterable getF() { return this._f; }
public Iterable getG() { return this._g; }
}
public static class MetadataSearchInput {
private Integer _something;···
public MetadataSearchInput(Map args) {
if (args != null) {
this._something = (Integer) args.get(\"something\");
}
}···
public Integer getSomething() { return this._something; }
}
public static class QueryUserArgs {
private Object _id;···
public QueryUserArgs(Map args) {
if (args != null) {
this._id = (Object) args.get(\"id\");
}
}···
public Object getId() { return this._id; }
}
public static class QuerySearchUserArgs {
private SearchUserInput _searchFields;···
public QuerySearchUserArgs(Map args) {
if (args != null) {
this._searchFields = new SearchUserInput((Map) args.get(\"searchFields\"));
}
}···
public SearchUserInput getSearchFields() { return this._searchFields; }
}
public enum ResultSort {
Asc(\"ASC\"),
Desc(\"DESC\");·····
public final String label;······
ResultSort(String label) {
this.label = label;
}·····
private static final Map BY_LABEL = new HashMap<>();·······
static {
for (ResultSort e : values()) {
BY_LABEL.put(e.label, e);
}
}·····
public static ResultSort valueOfLabel(String label) {
return BY_LABEL.get(label);
}
}···
public static class SearchUserInput {
private String _username;
private String _email;
private String _name;
private ResultSort _sort;
private MetadataSearchInput _metadata;···
public SearchUserInput(Map args) {
if (args != null) {
this._username = (String) args.get(\"username\");
this._email = (String) args.get(\"email\");
this._name = (String) args.get(\"name\");
this._sort = (ResultSort) args.get(\"sort\");
this._metadata = new MetadataSearchInput((Map) args.get(\"metadata\"));
}
}···
public String getUsername() { return this._username; }
public String getEmail() { return this._email; }
public String getName() { return this._name; }
public ResultSort getSort() { return this._sort; }
public MetadataSearchInput getMetadata() { return this._metadata; }
}
public static class UserFriendsArgs {
private Integer _skip;
private Integer _limit;···
public UserFriendsArgs(Map args) {
if (args != null) {
this._skip = (Integer) args.get(\"skip\");
this._limit = (Integer) args.get(\"limit\");
}
}···
public Integer getSkip() { return this._skip; }
public Integer getLimit() { return this._limit; }
}
public enum UserRole {
Admin(\"ADMIN\"),
User(\"USER\"),
Editor(\"EDITOR\");·····
public final String label;······
UserRole(String label) {
this.label = label;
}·····
private static final Map BY_LABEL = new HashMap<>();·······
static {
for (UserRole e : values()) {
BY_LABEL.put(e.label, e);
}
}·····
public static UserRole valueOfLabel(String label) {
return BY_LABEL.get(label);
}
}···
}
"
73 | const result = await plugin(schema, [], {}, { outputFile: OUTPUT_FILE });
74 |
> 75 | expect(result).toContain(`package com.java.generated;`);
| ^
76 | });
77 |
78 | it('Should use the package name provided from the config', async () => {
at Object.it (tests/java.spec.ts:75:22)
Test Suites: 1 failed, 1 total
Tests: 2 failed, 8 passed, 10 total
Snapshots: 0 total
Time: 3.373s, estimated 7s
Ran all test suites.
error Command failed with exit code 1.
lerna ERR! yarn run test exited 1 in '@graphql-codegen/java'
lerna WARN complete Waiting for 2 child processes to exit. CTRL-C to exit immediately.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.