java icon indicating copy to clipboard operation
java copied to clipboard

New concept: Optional

Open josealonso opened this issue 1 year ago • 22 comments

Write explanation for the Optional concept, as well as the test file, the stub implementation, the reference solution and other required files. Some files must be modified. This is a draft.

This solves #2555


Reviewer Resources:

Track Policies

josealonso avatar Feb 10 '25 23:02 josealonso

I just committed a first draft. Don't worry about the linting errors, I will sort them out during this week. I'd like to receive feedback about the reference solution and the test file, the bulk of the work is done.

  • Is there an exercise for the generics concept ? That is a prerequisite for this concept.
  • If that concept is not explained on the Java track, I can adapt it from other track.

@kahgoh @jagdish-15

josealonso avatar Feb 10 '25 23:02 josealonso

Thanks @josealonso! I plan to have a look at the draft soon.

In regards to the generics concept, it is covered as generics type.

kahgoh avatar Feb 11 '25 04:02 kahgoh

Thanks @josealonso! I plan to have a look at the draft soon.

In regards to the generics concept, it is covered as generics type.

Thanks for the link to the generic-types exercise!! Shame on me

josealonso avatar Feb 11 '25 18:02 josealonso

Which icon should I choose?

josealonso avatar Feb 11 '25 18:02 josealonso

Did you mean the icon for the exercise? They get added to exercism/icons repository, though that can be done after the exercise is added. We'll have to make one, but I think it will be the same icon as the original Tim From Marketing, but with a "2" in the top right corner. Compare Wizards and Warriors and Wizards and Warriors 2 for an example.

kahgoh avatar Feb 12 '25 13:02 kahgoh

Did you mean the icon for the exercise? They get added to exercism/icons repository, though that can be done after the exercise is added. We'll have to make one, but I think it will be the same icon as the original Tim From Marketing, but with a "2" in the top right corner. Compare Wizards and Warriors and Wizards and Warriors 2 for an example.

Who can make that icon? I'm sorry I don't know how to edit a simple icon :(

josealonso avatar Feb 14 '25 16:02 josealonso

I don't understand why the java-test-runner failed, @kahgoh. It probably has to do with some missing configuration files,

josealonso avatar Feb 15 '25 01:02 josealonso

Who can make that icon? I'm sorry I don't know how to edit a simple icon :(

That's fine, we can do that later. For now, let's just work on the concept content.

kahgoh avatar Feb 15 '25 13:02 kahgoh

I don't understand why the java-test-runner failed, @kahgoh. It probably has to do with some missing configuration files,

Its a bit hard to find, but this appears in the log:

tim-from-marketing-2: exemplar solution did not pass the tests

Are the tests passing locally for you?

kahgoh avatar Feb 15 '25 13:02 kahgoh

Are the tests passing locally for you?

Yes.

josealonso avatar Feb 17 '25 00:02 josealonso

Maybe this doc on configlet could be useful for you as well to check

manumafe98 avatar Feb 17 '25 23:02 manumafe98

Maybe this doc on configlet could be useful for you as well to check

Thanks, I went through it already. I'll have to read it again.

josealonso avatar Feb 19 '25 17:02 josealonso

@kahgoh, can you please go through these files and tell me if that's the right approach ? Thanks :)

josealonso avatar Mar 06 '25 13:03 josealonso

I will continue tomorrow.

josealonso avatar Mar 14 '25 02:03 josealonso

I will continue tomorrow.

No worries @josealonso . There's no hurry for this one, so feel free to take longer if you need to

kahgoh avatar Mar 14 '25 06:03 kahgoh

I will continue tomorrow.

No worries @josealonso . There's no hurry for this one, so feel free to take longer if you need to

  • The value of concepts.uuid is a zero-length string. I thought it had to match the exercises.uuid, but doing that produced an error, so I left it empty. It's the only error in the configlet phase.

  • The tests are failing to build even locally, it might be a configuration issue.

I addressed all the suggestions you made, except using List.of() instead of a function in the tests.

Please tell me how to fix the two errors mentioned above and fell free to suggest any improvements.

Thanks @kahgoh!

josealonso avatar Mar 14 '25 18:03 josealonso

The value of concepts.uuid is a zero-length string. I thought it had to match the exercises.uuid, but doing that produced an error, so I left it empty.

They are two different UUIDs. You can generate one using configlet uuid.

The tests are failing to build even locally, it might be a configuration issue.

I'm a little confused as to which solution to look at as there is one in src/reference/java and I can also see an implementation in src/main/java. I assume the one in src/main/java is just a work in progress (ultimately, we want to end up with the working one in src/referece/java). Could you let me know how you are currently testing?

Btw, to test against the reference solution, you can go into the exercises directory and run ./gradlew :concept:tim-from-marketing-2:test.

kahgoh avatar Mar 19 '25 09:03 kahgoh

I've just tried running the tests locally. The failing tests have the following messages:

EmployeeDatabaseTest > Retrieve employee details by id when department is null and name is not null FAILED
    org.opentest4j.AssertionFailedError:
    expected: "No employee found for id: 6"
     but was: "6 - Alice - null"
        at [email protected]/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
        at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
        at app//EmployeeDatabaseTest.retrieveEmployeeDetailsById_whenDepartmentIsNull(EmployeeDatabaseTest.java:92)

and

EmployeeDatabaseTest > Retrieve employee details by id when the id does not exist FAILED
    org.opentest4j.AssertionFailedError:
    expected: "No employee found for id: 10"
     but was: "That id does not exist: 10"
        at [email protected]/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
        at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
        at app//EmployeeDatabaseTest.retrieveEmployeeDetailsById_forANonExistingId(EmployeeDatabaseTest.java:100)

I ran them against the .meta/src/reference using gradlew :concept:tim-from-marketing-2:test. Can you see why these test may fail?

kahgoh avatar Mar 19 '25 12:03 kahgoh

The value of concepts.uuid is a zero-length string. I thought it had to match the exercises.uuid, but doing that produced an error, so I left it empty.

They are two different UUIDs. You can generate one using configlet uuid.

The tests are failing to build even locally, it might be a configuration issue.

I'm a little confused as to which solution to look at as there is one in src/reference/java and I can also see an implementation in src/main/java. I assume the one in src/main/java is just a work in progress (ultimately, we want to end up with the working one in src/referece/java). Could you let me know how you are currently testing? Oh, sorry, I thought both files had the same content. I changed only the file name, as you suggested. I might have changed something else without realizing it. Let me take a look tonight (in Europe). Thanks for the hint, because I couldn't run the tests locally.

Btw, to test against the reference solution, you can go into the exercises directory and run ./gradlew :concept:tim-from-marketing-2:test. Thanks, hopefully this command will work locally!

josealonso avatar Mar 19 '25 13:03 josealonso

I've just tried running the tests locally. The failing tests have the following messages:

EmployeeDatabaseTest > Retrieve employee details by id when department is null and name is not null FAILED
    org.opentest4j.AssertionFailedError:
    expected: "No employee found for id: 6"
     but was: "6 - Alice - null"
        at [email protected]/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
        at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
        at app//EmployeeDatabaseTest.retrieveEmployeeDetailsById_whenDepartmentIsNull(EmployeeDatabaseTest.java:92)

and

EmployeeDatabaseTest > Retrieve employee details by id when the id does not exist FAILED
    org.opentest4j.AssertionFailedError:
    expected: "No employee found for id: 10"
     but was: "That id does not exist: 10"
        at [email protected]/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
        at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
        at app//EmployeeDatabaseTest.retrieveEmployeeDetailsById_forANonExistingId(EmployeeDatabaseTest.java:100)

I ran them against the .meta/src/reference using gradlew :concept:tim-from-marketing-2:test. Can you see why these test may fail?

I'll let you know if I can run the tests locally. Thanks!

josealonso avatar Mar 19 '25 13:03 josealonso

I haven't made any progress on this branch since last March, shame on me. I think most of the work is done, but I'm not motivated to follow. So I'm going to unassign me. Thanks for your time and patience, @kahgoh.

josealonso avatar Aug 30 '25 10:08 josealonso

No worries @josealonso. Thanks for trying and letting us know.

kahgoh avatar Aug 30 '25 11:08 kahgoh